From 4e724ba92291cb30f87db7360f84b8e8bf9d16fe Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Tue, 1 Sep 2020 17:33:49 +0800 Subject: [PATCH] android:when in DoricPanelFragment,do not observe Lifecycle --- .../src/main/java/pub/doric/DoricPanelFragment.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doric-android/doric/src/main/java/pub/doric/DoricPanelFragment.java b/doric-android/doric/src/main/java/pub/doric/DoricPanelFragment.java index 9137e8e5..56922b49 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricPanelFragment.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricPanelFragment.java @@ -75,6 +75,9 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator { } } } + if (getContext() instanceof LifecycleOwner) { + ((LifecycleOwner) getContext()).getLifecycle().removeObserver(doricPanel); + } } @Override @@ -116,7 +119,7 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator { @Override public void onResume() { super.onResume(); - if (!(getActivity() instanceof LifecycleOwner) && doricPanel != null) { + if (doricPanel != null) { doricPanel.onActivityResume(); } } @@ -124,7 +127,7 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator { @Override public void onPause() { super.onPause(); - if (!(getActivity() instanceof LifecycleOwner) && doricPanel != null) { + if (doricPanel != null) { doricPanel.onActivityPause(); } } @@ -132,8 +135,7 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator { @Override public void onDestroy() { super.onDestroy(); - if ((getActivity() == null || !getActivity().isFinishing() || !(getActivity() instanceof LifecycleOwner)) - && doricPanel != null) { + if (doricPanel != null) { doricPanel.onActivityDestroy(); } }