Skip to content

Commit

Permalink
Revert D6531148: Fix BadTokenException and IllegalArgmentException th…
Browse files Browse the repository at this point in the history
…rown when showing or dismissing Modal

Differential Revision: D6531148

fbshipit-source-id: a90cc38f98d6b86151539abd2a07bfcf1c253a5f
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jan 5, 2018
1 parent c9ff0bc commit e57a43b
Showing 1 changed file with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ public void onDropInstance() {

private void dismiss() {
if (mDialog != null) {
Activity currentActivity = getCurrentActivity();
if (mDialog.isShowing() && (currentActivity == null || !currentActivity.isFinishing())) {
mDialog.dismiss();
}
mDialog.dismiss();
mDialog = null;

// We need to remove the mHostView from the parent
Expand Down Expand Up @@ -212,9 +209,8 @@ protected void showOrUpdate() {
} else if (mAnimationType.equals("slide")) {
theme = R.style.Theme_FullScreenDialogAnimatedSlide;
}
Activity currentActivity = getCurrentActivity();
Context context = currentActivity == null ? getContext() : currentActivity;
mDialog = new Dialog(context, theme);
mDialog = new Dialog(getContext(), theme);

mDialog.setContentView(getContentView());
updateProperties();

Expand All @@ -237,7 +233,7 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
} else {
// 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
Activity currentActivity = getCurrentActivity();
Activity currentActivity = ((ReactContext) getContext()).getCurrentActivity();
if (currentActivity != null) {
return currentActivity.onKeyUp(keyCode, event);
}
Expand All @@ -251,13 +247,7 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (mHardwareAccelerated) {
mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
}
if (currentActivity == null || !currentActivity.isFinishing()) {
mDialog.show();
}
}

private @Nullable Activity getCurrentActivity() {
return ((ReactContext) getContext()).getCurrentActivity();
mDialog.show();
}

/**
Expand Down

0 comments on commit e57a43b

Please sign in to comment.