From 458638bd4271b66b61aee0daadf41b8f0861cd82 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 6 Dec 2019 10:15:55 +0800 Subject: [PATCH] feat:update template --- target/android/app/build.gradle | 9 +++++++++ .../java/pub/doric/example/MainActivity.java | 20 +++++++++++++++---- .../app/src/main/res/layout/activity_main.xml | 4 ++-- .../app/src/main/res/values/styles.xml | 2 +- target/js/$.ts | 5 ++++- 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/target/android/app/build.gradle b/target/android/app/build.gradle index 7b514939..7deff3cf 100644 --- a/target/android/app/build.gradle +++ b/target/android/app/build.gradle @@ -31,4 +31,13 @@ android { implementation "pub.doric:core:0.1.0" debugImplementation "pub.doric:core:0.1.0" } +} + +afterEvaluate { + buildJSBundle.exec() +} + +task buildJSBundle(type: Exec) { + workingDir project.rootDir.getParent() + "/js" + commandLine 'doric', 'build' } \ No newline at end of file diff --git a/target/android/app/src/main/java/pub/doric/example/MainActivity.java b/target/android/app/src/main/java/pub/doric/example/MainActivity.java index 06285095..adcd9138 100644 --- a/target/android/app/src/main/java/pub/doric/example/MainActivity.java +++ b/target/android/app/src/main/java/pub/doric/example/MainActivity.java @@ -5,17 +5,29 @@ import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; -import pub.doric.DoricPanel; -import pub.doric.utils.DoricUtils; +import pub.doric.DoricFragment; public class MainActivity extends AppCompatActivity { private final String BUNDLE_NAME = "__$__"; + private DoricFragment doricFragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - DoricPanel doricPanel = findViewById(R.id.doric_panel); - doricPanel.config(DoricUtils.readAssetFile(BUNDLE_NAME + ".js"), BUNDLE_NAME); + if (savedInstanceState == null) { + String scheme = "assets://" + BUNDLE_NAME + ".js"; + this.doricFragment = DoricFragment.newInstance(scheme, BUNDLE_NAME); + this.getSupportFragmentManager().beginTransaction().add(R.id.root, this.doricFragment).commit(); + } + } + + @Override + public void onBackPressed() { + if (this.doricFragment.canPop()) { + this.doricFragment.pop(); + } else { + super.onBackPressed(); + } } } diff --git a/target/android/app/src/main/res/layout/activity_main.xml b/target/android/app/src/main/res/layout/activity_main.xml index fd930106..c4576e97 100644 --- a/target/android/app/src/main/res/layout/activity_main.xml +++ b/target/android/app/src/main/res/layout/activity_main.xml @@ -1,5 +1,5 @@ - \ No newline at end of file diff --git a/target/android/app/src/main/res/values/styles.xml b/target/android/app/src/main/res/values/styles.xml index 5885930d..0eb88fe3 100644 --- a/target/android/app/src/main/res/values/styles.xml +++ b/target/android/app/src/main/res/values/styles.xml @@ -1,7 +1,7 @@ -