mirror of
https://github.com/status-im/react-native.git
synced 2025-02-27 00:20:31 +00:00
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
This commit is contained in:
parent
ae6afcf3f6
commit
bf79352e4f
@ -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.content.DialogInterface.OnDismissListener;
|
||||
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 class DialogModule extends ReactContextBaseJavaModule implements Lifecycl
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user