Skip to content
Permalink
Browse files

fix dialogmodule crashing with no fragment manager in onHostResume

Summary: This can happen now, we shouldn't crash. `showAlert` will crash instead if JS tries to call it.

Reviewed By: lexs

Differential Revision: D3450018

fbshipit-source-id: bbc062b357315f26ee98ed3b3a59db71dc5fc74a
  • Loading branch information
foghina authored and Facebook Github Bot committed Jun 17, 2016
1 parent ae6afcf commit bf79352e4f149cbc66729ffe263c6242e675c996
@@ -6,6 +6,7 @@ android_library(
deps = [
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/android/support/v4:lib-support-v4'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
@@ -20,6 +20,7 @@
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.LifecycleEventListener;
@@ -198,11 +199,11 @@ public void onHostResume() {
mIsInForeground = true;
// Check if a dialog has been created while the host was paused, so that we can show it now.
FragmentManagerHelper fragmentManagerHelper = getFragmentManagerHelper();
Assertions.assertNotNull(
fragmentManagerHelper,
"Attached DialogModule to host with pending alert but no FragmentManager " +
"(not attached to an Activity).");
fragmentManagerHelper.showPendingAlert();
if (fragmentManagerHelper != null) {
fragmentManagerHelper.showPendingAlert();
} else {
FLog.w(DialogModule.class, "onHostResume called but no FragmentManager found");
}
}

@ReactMethod

0 comments on commit bf79352

Please sign in to comment.
You can’t perform that action at this time.