diff --git a/doric-android/doric/src/main/java/pub/doric/DoricContext.java b/doric-android/doric/src/main/java/pub/doric/DoricContext.java index 7b5d571a..55f0f7e7 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricContext.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricContext.java @@ -101,6 +101,7 @@ public class DoricContext { this.mContextId = contextId; this.source = source; this.extra = extra; + callEntity(DoricConstant.DORIC_ENTITY_CREATE); } public String getSource() { @@ -124,7 +125,6 @@ public class DoricContext { .put("height", height) .toJSONObject(); callEntity(DoricConstant.DORIC_ENTITY_INIT, this.initParams, extra); - callEntity(DoricConstant.DORIC_ENTITY_CREATE); } public AsyncResult callEntity(String methodName, Object... args) { diff --git a/doric-android/doric/src/main/java/pub/doric/DoricPanel.java b/doric-android/doric/src/main/java/pub/doric/DoricPanel.java index be87ac91..97f3a79d 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricPanel.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricPanel.java @@ -56,6 +56,7 @@ public class DoricPanel extends FrameLayout implements LifecycleObserver { public void config(String script, String alias, String extra) { DoricContext doricContext = DoricContext.create(getContext(), script, alias, extra); + doricContext.onShow(); config(doricContext); } @@ -65,10 +66,6 @@ public class DoricPanel extends FrameLayout implements LifecycleObserver { if (getMeasuredWidth() != 0 && getMeasuredHeight() != 0) { mDoricContext.init(DoricUtils.px2dp(getMeasuredWidth()), DoricUtils.px2dp(getMeasuredHeight())); } - if (getContext() instanceof LifecycleOwner - && ((LifecycleOwner) getContext()).getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) { - mDoricContext.onShow(); - } } @Override diff --git a/doric-iOS/Pod/Classes/DoricPanel.m b/doric-iOS/Pod/Classes/DoricPanel.m index fb8463eb..2fae084b 100644 --- a/doric-iOS/Pod/Classes/DoricPanel.m +++ b/doric-iOS/Pod/Classes/DoricPanel.m @@ -28,6 +28,7 @@ - (void)config:(NSString *)script alias:(NSString *)alias extra:(NSString *)extr [self.view addSubview:it]; }]]; }]; + [self.doricContext onShow]; } - (void)viewWillLayoutSubviews {