Have Modal dismiss Dialog when the ReactInstance goes away
Reviewed By: angelahess Differential Revision: D3252808 fb-gh-sync-id: 1f3085412f409581f161cf2151b251e818851d84 fbshipit-source-id: 1f3085412f409581f161cf2151b251e818851d84
This commit is contained in:
parent
0a7a228fbb
commit
20d53b1f23
|
@ -24,6 +24,7 @@ import android.view.WindowManager;
|
|||
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.R;
|
||||
import com.facebook.react.bridge.LifecycleEventListener;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.common.annotations.VisibleForTesting;
|
||||
import com.facebook.react.uimanager.JSTouchDispatcher;
|
||||
|
@ -44,7 +45,7 @@ import com.facebook.react.views.view.ReactViewGroup;
|
|||
* DialogRootViewGroup were part of the hierarchy. Therefore, we forward all view changes
|
||||
* around addition and removal of views to the DialogRootViewGroup.
|
||||
*/
|
||||
public class ReactModalHostView extends ViewGroup {
|
||||
public class ReactModalHostView extends ViewGroup implements LifecycleEventListener {
|
||||
|
||||
// This listener is called when the user presses KeyEvent.KEYCODE_BACK
|
||||
// An event is then passed to JS which can either close or not close the Modal by setting the
|
||||
|
@ -66,6 +67,7 @@ public class ReactModalHostView extends ViewGroup {
|
|||
|
||||
public ReactModalHostView(Context context) {
|
||||
super(context);
|
||||
((ReactContext) context).addLifecycleEventListener(this);
|
||||
|
||||
mHostView = new DialogRootViewGroup(context);
|
||||
}
|
||||
|
@ -136,6 +138,22 @@ public class ReactModalHostView extends ViewGroup {
|
|||
mPropertyRequiresNewDialog = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostResume() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostPause() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostDestroy() {
|
||||
// Dismiss the dialog if it is present
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public @Nullable Dialog getDialog() {
|
||||
return mDialog;
|
||||
|
|
Loading…
Reference in New Issue