feat:fix lifecycle call not exactly right
This commit is contained in:
parent
88a8db247c
commit
8f693b451d
@ -60,8 +60,10 @@ public class DoricPanel extends FrameLayout implements LifecycleObserver {
|
||||
public void config(String script, String alias, String extra) {
|
||||
DoricContext doricContext = DoricContext.create(getContext(), script, alias, extra);
|
||||
config(doricContext);
|
||||
if (getContext() instanceof LifecycleOwner && ((LifecycleOwner) getContext()).getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
|
||||
doricContext.onShow();
|
||||
}
|
||||
}
|
||||
|
||||
public void config(DoricContext doricContext) {
|
||||
mDoricContext = doricContext;
|
||||
|
@ -26,6 +26,7 @@ import android.widget.FrameLayout;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
@ -97,19 +98,23 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (!(getActivity() instanceof LifecycleOwner)) {
|
||||
doricPanel.onActivityResume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (!(getActivity() instanceof LifecycleOwner)) {
|
||||
doricPanel.onActivityPause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (getActivity() == null || !getActivity().isFinishing()) {
|
||||
if (getActivity() == null || !getActivity().isFinishing() || !(getActivity() instanceof LifecycleOwner)) {
|
||||
doricPanel.onActivityDestroy();
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,9 @@ - (void)config:(NSString *)script alias:(NSString *)alias extra:(NSString *)extr
|
||||
[self.view addSubview:it];
|
||||
}]];
|
||||
}];
|
||||
if (self.parentViewController != nil) {
|
||||
[self.doricContext onShow];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillLayoutSubviews {
|
||||
|
Reference in New Issue
Block a user