Permalink
Browse files

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
  • Loading branch information...
mdvacca authored and facebook-github-bot committed Nov 3, 2018
1 parent 8b275a8 commit 38e01a20c343e60d5f8cd92fb26454e9940565df
Showing with 4 additions and 7 deletions.
  1. +4 −7 ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.java
@@ -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;
@@ -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 {
@@ -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();
}
}

0 comments on commit 38e01a2

Please sign in to comment.