Skip to content

Commit 38e01a2

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Fix IllegalStateException when dismissing DialogManager
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
1 parent 8b275a8 commit 38e01a2

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77

88
package com.facebook.react.modules.dialog;
99

10-
import javax.annotation.Nullable;
11-
12-
import java.util.Map;
13-
1410
import android.app.Activity;
1511
import android.content.DialogInterface;
1612
import android.content.DialogInterface.OnClickListener;
1713
import android.content.DialogInterface.OnDismissListener;
1814
import android.os.Bundle;
1915
import android.support.v4.app.FragmentActivity;
20-
2116
import com.facebook.common.logging.FLog;
2217
import com.facebook.react.bridge.Callback;
2318
import com.facebook.react.bridge.LifecycleEventListener;
@@ -29,6 +24,8 @@
2924
import com.facebook.react.bridge.UiThreadUtil;
3025
import com.facebook.react.common.MapBuilder;
3126
import com.facebook.react.module.annotations.ReactModule;
27+
import java.util.Map;
28+
import javax.annotation.Nullable;
3229

3330
@ReactModule(name = DialogModule.NAME)
3431
public class DialogModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
@@ -110,13 +107,13 @@ private void dismissExisting() {
110107
if (isUsingSupportLibrary()) {
111108
SupportAlertFragment oldFragment =
112109
(SupportAlertFragment) mSupportFragmentManager.findFragmentByTag(FRAGMENT_TAG);
113-
if (oldFragment != null) {
110+
if (oldFragment != null && oldFragment.isResumed()) {
114111
oldFragment.dismiss();
115112
}
116113
} else {
117114
AlertFragment oldFragment =
118115
(AlertFragment) mFragmentManager.findFragmentByTag(FRAGMENT_TAG);
119-
if (oldFragment != null) {
116+
if (oldFragment != null && oldFragment.isResumed()) {
120117
oldFragment.dismiss();
121118
}
122119
}

0 commit comments

Comments
 (0)