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