android:when in DoricPanelFragment,do not observe Lifecycle

This commit is contained in:
pengfei.zhou 2020-09-01 17:33:49 +08:00 committed by osborn
parent 6484439852
commit 4e724ba922

View File

@ -75,6 +75,9 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
} }
} }
} }
if (getContext() instanceof LifecycleOwner) {
((LifecycleOwner) getContext()).getLifecycle().removeObserver(doricPanel);
}
} }
@Override @Override
@ -116,7 +119,7 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (!(getActivity() instanceof LifecycleOwner) && doricPanel != null) { if (doricPanel != null) {
doricPanel.onActivityResume(); doricPanel.onActivityResume();
} }
} }
@ -124,7 +127,7 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
if (!(getActivity() instanceof LifecycleOwner) && doricPanel != null) { if (doricPanel != null) {
doricPanel.onActivityPause(); doricPanel.onActivityPause();
} }
} }
@ -132,8 +135,7 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
if ((getActivity() == null || !getActivity().isFinishing() || !(getActivity() instanceof LifecycleOwner)) if (doricPanel != null) {
&& doricPanel != null) {
doricPanel.onActivityDestroy(); doricPanel.onActivityDestroy();
} }
} }