Skip to content

Commit e57a43b

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Revert D6531148: Fix BadTokenException and IllegalArgmentException thrown when showing or dismissing Modal
Differential Revision: D6531148 fbshipit-source-id: a90cc38f98d6b86151539abd2a07bfcf1c253a5f
1 parent c9ff0bc commit e57a43b

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,7 @@ public void onDropInstance() {
128128

129129
private void dismiss() {
130130
if (mDialog != null) {
131-
Activity currentActivity = getCurrentActivity();
132-
if (mDialog.isShowing() && (currentActivity == null || !currentActivity.isFinishing())) {
133-
mDialog.dismiss();
134-
}
131+
mDialog.dismiss();
135132
mDialog = null;
136133

137134
// We need to remove the mHostView from the parent
@@ -212,9 +209,8 @@ protected void showOrUpdate() {
212209
} else if (mAnimationType.equals("slide")) {
213210
theme = R.style.Theme_FullScreenDialogAnimatedSlide;
214211
}
215-
Activity currentActivity = getCurrentActivity();
216-
Context context = currentActivity == null ? getContext() : currentActivity;
217-
mDialog = new Dialog(context, theme);
212+
mDialog = new Dialog(getContext(), theme);
213+
218214
mDialog.setContentView(getContentView());
219215
updateProperties();
220216

@@ -237,7 +233,7 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
237233
} else {
238234
// We redirect the rest of the key events to the current activity, since the activity
239235
// expects to receive those events and react to them, ie. in the case of the dev menu
240-
Activity currentActivity = getCurrentActivity();
236+
Activity currentActivity = ((ReactContext) getContext()).getCurrentActivity();
241237
if (currentActivity != null) {
242238
return currentActivity.onKeyUp(keyCode, event);
243239
}
@@ -251,13 +247,7 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
251247
if (mHardwareAccelerated) {
252248
mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
253249
}
254-
if (currentActivity == null || !currentActivity.isFinishing()) {
255-
mDialog.show();
256-
}
257-
}
258-
259-
private @Nullable Activity getCurrentActivity() {
260-
return ((ReactContext) getContext()).getCurrentActivity();
250+
mDialog.show();
261251
}
262252

263253
/**

0 commit comments

Comments
 (0)