add lifecycle
This commit is contained in:
parent
9a13cdb3ad
commit
4d8e11b660
@ -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<JSDecoder> 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<Boolean>() {
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
@ -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__";
|
||||
}
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user