Browse Source

Catch rare RuntimeException in setRoot when waitForRender = true (#5428)

When setRoot is called with `waitForRender=true`, check if the root view is destroyed before displaying it.
Arman Dezfuli-Arjomandi 5 years ago
parent
commit
b04858190e

+ 6
- 2
lib/android/app/src/main/java/com/reactnativenavigation/presentation/RootPresenter.java View File

@@ -42,8 +42,12 @@ public class RootPresenter {
42 42
         if (options.animations.setRoot.waitForRender.isTrue()) {
43 43
             root.getView().setAlpha(0);
44 44
             root.addOnAppearedListener(() -> {
45
-                root.getView().setAlpha(1);
46
-                animateSetRootAndReportSuccess(root, listener, options);
45
+                if (root.isDestroyed()) {
46
+                    listener.onError("Could not set root - Waited for the view to become visible but it was destroyed");
47
+                } else {
48
+                    root.getView().setAlpha(1);
49
+                    animateSetRootAndReportSuccess(root, listener, options);
50
+                }
47 51
             });
48 52
         } else {
49 53
             animateSetRootAndReportSuccess(root, listener, options);