diff --git a/Android/doric/src/main/java/com/github/penfeizhou/doric/DoricContext.java b/Android/doric/src/main/java/com/github/penfeizhou/doric/DoricContext.java index add8ee4f..5dd4046e 100644 --- a/Android/doric/src/main/java/com/github/penfeizhou/doric/DoricContext.java +++ b/Android/doric/src/main/java/com/github/penfeizhou/doric/DoricContext.java @@ -4,6 +4,7 @@ import android.content.Context; import com.github.penfeizhou.doric.async.AsyncResult; import com.github.penfeizhou.doric.plugin.DoricJavaPlugin; +import com.github.penfeizhou.doric.utils.DoricConstant; import com.github.penfeizhou.doric.utils.DoricMetaInfo; import com.github.penfeizhou.doric.shader.RootNode; import com.github.pengfeizhou.jscore.JSDecoder; @@ -34,7 +35,9 @@ public class DoricContext { } public static DoricContext create(Context context, String script, String source) { - return DoricContextManager.getInstance().createContext(context, script, source); + DoricContext doricContext = DoricContextManager.getInstance().createContext(context, script, source); + doricContext.callEntity(DoricConstant.DORIC_ENTITY_CREATE); + return doricContext; } public AsyncResult callEntity(String methodName, Object... args) { @@ -58,6 +61,7 @@ public class DoricContext { } public void teardown() { + callEntity(DoricConstant.DORIC_ENTITY_DESTROY); DoricContextManager.getInstance().destroyContext(this).setCallback(new AsyncResult.Callback() { @Override public void onResult(Boolean result) { @@ -88,4 +92,12 @@ public class DoricContext { public void reload(String script) { getDriver().createContext(mContextId, script, source); } + + public void onShow() { + callEntity(DoricConstant.DORIC_ENTITY_SHOW); + } + + public void onHidden() { + callEntity(DoricConstant.DORIC_ENTITY_HIDDEN); + } } diff --git a/Android/doric/src/main/java/com/github/penfeizhou/doric/utils/DoricConstant.java b/Android/doric/src/main/java/com/github/penfeizhou/doric/utils/DoricConstant.java index afabac4b..7b91511e 100644 --- a/Android/doric/src/main/java/com/github/penfeizhou/doric/utils/DoricConstant.java +++ b/Android/doric/src/main/java/com/github/penfeizhou/doric/utils/DoricConstant.java @@ -47,4 +47,9 @@ public class DoricConstant { public static final String DORIC_ENTITY_RESPONSE = "__response__"; + public static final String DORIC_ENTITY_INIT = "__init__"; + public static final String DORIC_ENTITY_CREATE = "__onCreate__"; + public static final String DORIC_ENTITY_DESTROY = "__onDestroy__"; + public static final String DORIC_ENTITY_SHOW = "__onShow__"; + public static final String DORIC_ENTITY_HIDDEN = "__onHidden__"; } diff --git a/js-framework/src/ui/panel.ts b/js-framework/src/ui/panel.ts index af056a71..3e043d17 100644 --- a/js-framework/src/ui/panel.ts +++ b/js-framework/src/ui/panel.ts @@ -18,7 +18,7 @@ type Frame = { width: number, height: number } export abstract class Panel { context?: any onCreate() { } - onDestory() { } + onDestroy() { } onShow() { } onHidden() { } @@ -30,6 +30,7 @@ export abstract class Panel { getRootView() { return this.__root__ } + getInitData() { return this.__data__ } @@ -48,8 +49,8 @@ export abstract class Panel { } @NativeCall - private __onDestory__() { - this.onDestory() + private __onDestroy__() { + this.onDestroy() } @NativeCall