diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.java index 4af221dd4..2fb42c594 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.java @@ -62,7 +62,7 @@ public class ReactModalHostManager extends ViewGroupManager @Override public void onDropViewInstance(ReactModalHostView view) { super.onDropViewInstance(view); - view.dismiss(); + view.onDropInstance(); } @ReactProp(name = "animationType") diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java index 24b33892a..48b66db9f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java @@ -109,7 +109,12 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe // Those will be handled by the mHostView which lives in the dialog } - public void dismiss() { + public void onDropInstance() { + ((ReactContext) getContext()).removeLifecycleEventListener(this); + dismiss(); + } + + private void dismiss() { if (mDialog != null) { mDialog.dismiss(); mDialog = null; @@ -140,18 +145,20 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe @Override public void onHostResume() { - // do nothing + // We show the dialog again when the host resumes + showOrUpdate(); } @Override public void onHostPause() { - // do nothing + // We dismiss the dialog and reconstitute it onHostResume + dismiss(); } @Override public void onHostDestroy() { - // Dismiss the dialog if it is present - dismiss(); + // Drop the instance if the host is destroyed which will dismiss the dialog + onDropInstance(); } @VisibleForTesting