|
28 | 28 | import com.facebook.react.bridge.ReactMethod;
|
29 | 29 | import com.facebook.react.bridge.ReadableArray;
|
30 | 30 | import com.facebook.react.bridge.ReadableMap;
|
| 31 | +import com.facebook.react.bridge.UiThreadUtil; |
31 | 32 | import com.facebook.react.common.MapBuilder;
|
32 | 33 | import com.facebook.react.module.annotations.ReactModule;
|
33 | 34 |
|
@@ -95,6 +96,7 @@ public FragmentManagerHelper(android.app.FragmentManager fragmentManager) {
|
95 | 96 | }
|
96 | 97 |
|
97 | 98 | public void showPendingAlert() {
|
| 99 | + UiThreadUtil.assertOnUiThread(); |
98 | 100 | if (mFragmentToShow == null) {
|
99 | 101 | return;
|
100 | 102 | }
|
@@ -123,6 +125,8 @@ private void dismissExisting() {
|
123 | 125 | }
|
124 | 126 |
|
125 | 127 | public void showNewAlert(boolean isInForeground, Bundle arguments, Callback actionCallback) {
|
| 128 | + UiThreadUtil.assertOnUiThread(); |
| 129 | + |
126 | 130 | dismissExisting();
|
127 | 131 |
|
128 | 132 | AlertFragmentListener actionListener =
|
@@ -218,8 +222,8 @@ public void onHostResume() {
|
218 | 222 | public void showAlert(
|
219 | 223 | ReadableMap options,
|
220 | 224 | Callback errorCallback,
|
221 |
| - Callback actionCallback) { |
222 |
| - FragmentManagerHelper fragmentManagerHelper = getFragmentManagerHelper(); |
| 225 | + final Callback actionCallback) { |
| 226 | + final FragmentManagerHelper fragmentManagerHelper = getFragmentManagerHelper(); |
223 | 227 | if (fragmentManagerHelper == null) {
|
224 | 228 | errorCallback.invoke("Tried to show an alert while not attached to an Activity");
|
225 | 229 | return;
|
@@ -253,7 +257,13 @@ public void showAlert(
|
253 | 257 | args.putBoolean(KEY_CANCELABLE, options.getBoolean(KEY_CANCELABLE));
|
254 | 258 | }
|
255 | 259 |
|
256 |
| - fragmentManagerHelper.showNewAlert(mIsInForeground, args, actionCallback); |
| 260 | + UiThreadUtil.runOnUiThread(new Runnable() { |
| 261 | + @Override |
| 262 | + public void run() { |
| 263 | + fragmentManagerHelper.showNewAlert(mIsInForeground, args, actionCallback); |
| 264 | + } |
| 265 | + }); |
| 266 | + |
257 | 267 | }
|
258 | 268 |
|
259 | 269 | /**
|
|
0 commit comments