Align lifecycle timing for Android and iOS

This commit is contained in:
pengfei.zhou 2020-02-29 14:17:38 +08:00 committed by osborn
parent e0055f437d
commit eb6ba3ee36
3 changed files with 3 additions and 5 deletions

View File

@ -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<JSDecoder> callEntity(String methodName, Object... args) {

View File

@ -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

View File

@ -28,6 +28,7 @@ - (void)config:(NSString *)script alias:(NSString *)alias extra:(NSString *)extr
[self.view addSubview:it];
}]];
}];
[self.doricContext onShow];
}
- (void)viewWillLayoutSubviews {