mirror of
https://github.com/status-im/react-native.git
synced 2025-02-06 14:43:49 +00:00
Revert D6531148: Fix BadTokenException and IllegalArgmentException thrown when showing or dismissing Modal
Differential Revision: D6531148 fbshipit-source-id: a90cc38f98d6b86151539abd2a07bfcf1c253a5f
This commit is contained in:
parent
c9ff0bc212
commit
e57a43b97a
@ -128,10 +128,7 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
|||||||
|
|
||||||
private void dismiss() {
|
private void dismiss() {
|
||||||
if (mDialog != null) {
|
if (mDialog != null) {
|
||||||
Activity currentActivity = getCurrentActivity();
|
mDialog.dismiss();
|
||||||
if (mDialog.isShowing() && (currentActivity == null || !currentActivity.isFinishing())) {
|
|
||||||
mDialog.dismiss();
|
|
||||||
}
|
|
||||||
mDialog = null;
|
mDialog = null;
|
||||||
|
|
||||||
// We need to remove the mHostView from the parent
|
// We need to remove the mHostView from the parent
|
||||||
@ -212,9 +209,8 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
|||||||
} else if (mAnimationType.equals("slide")) {
|
} else if (mAnimationType.equals("slide")) {
|
||||||
theme = R.style.Theme_FullScreenDialogAnimatedSlide;
|
theme = R.style.Theme_FullScreenDialogAnimatedSlide;
|
||||||
}
|
}
|
||||||
Activity currentActivity = getCurrentActivity();
|
mDialog = new Dialog(getContext(), theme);
|
||||||
Context context = currentActivity == null ? getContext() : currentActivity;
|
|
||||||
mDialog = new Dialog(context, theme);
|
|
||||||
mDialog.setContentView(getContentView());
|
mDialog.setContentView(getContentView());
|
||||||
updateProperties();
|
updateProperties();
|
||||||
|
|
||||||
@ -237,7 +233,7 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
|||||||
} else {
|
} else {
|
||||||
// We redirect the rest of the key events to the current activity, since the activity
|
// We redirect the rest of the key events to the current activity, since the activity
|
||||||
// expects to receive those events and react to them, ie. in the case of the dev menu
|
// expects to receive those events and react to them, ie. in the case of the dev menu
|
||||||
Activity currentActivity = getCurrentActivity();
|
Activity currentActivity = ((ReactContext) getContext()).getCurrentActivity();
|
||||||
if (currentActivity != null) {
|
if (currentActivity != null) {
|
||||||
return currentActivity.onKeyUp(keyCode, event);
|
return currentActivity.onKeyUp(keyCode, event);
|
||||||
}
|
}
|
||||||
@ -251,13 +247,7 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
|||||||
if (mHardwareAccelerated) {
|
if (mHardwareAccelerated) {
|
||||||
mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
|
mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
|
||||||
}
|
}
|
||||||
if (currentActivity == null || !currentActivity.isFinishing()) {
|
mDialog.show();
|
||||||
mDialog.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private @Nullable Activity getCurrentActivity() {
|
|
||||||
return ((ReactContext) getContext()).getCurrentActivity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user