Skip to content

Commit

Permalink
Fix IllegalStateException when dismissing DialogManager
Browse files Browse the repository at this point in the history
Summary: This diff fixes a IllegalStateException that can happen because of a race condition when using DialogManager

Reviewed By: fkgozali

Differential Revision: D12899432

fbshipit-source-id: 98fb7c1ee1d292a959628a33c8a2dd5a6d93e328
  • Loading branch information
mdvacca authored and facebook-github-bot committed Nov 3, 2018
1 parent 8b275a8 commit 38e01a2
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@

package com.facebook.react.modules.dialog;

import javax.annotation.Nullable;

import java.util.Map;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnDismissListener;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.LifecycleEventListener;
Expand All @@ -29,6 +24,8 @@
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.module.annotations.ReactModule;
import java.util.Map;
import javax.annotation.Nullable;

@ReactModule(name = DialogModule.NAME)
public class DialogModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
Expand Down Expand Up @@ -110,13 +107,13 @@ private void dismissExisting() {
if (isUsingSupportLibrary()) {
SupportAlertFragment oldFragment =
(SupportAlertFragment) mSupportFragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (oldFragment != null) {
if (oldFragment != null && oldFragment.isResumed()) {
oldFragment.dismiss();
}
} else {
AlertFragment oldFragment =
(AlertFragment) mFragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (oldFragment != null) {
if (oldFragment != null && oldFragment.isResumed()) {
oldFragment.dismiss();
}
}
Expand Down

0 comments on commit 38e01a2

Please sign in to comment.