Browse Source

Fix EmptyStackException (#2746)

Varun Gupta 6 years ago
parent
commit
674a43d0a8

+ 10
- 1
android/app/src/main/java/com/reactnativenavigation/views/SnackbarAndFabContainer.java View File

@@ -11,6 +11,9 @@ import com.reactnativenavigation.events.Subscriber;
11 11
 import com.reactnativenavigation.layouts.Layout;
12 12
 import com.reactnativenavigation.params.FabParams;
13 13
 import com.reactnativenavigation.params.SnackbarParams;
14
+import com.reactnativenavigation.screens.Screen;
15
+
16
+import java.util.EmptyStackException;
14 17
 
15 18
 public class SnackbarAndFabContainer extends CoordinatorLayout implements Snakbar.OnDismissListener, Subscriber{
16 19
     private Snakbar snakbar;
@@ -67,7 +70,13 @@ public class SnackbarAndFabContainer extends CoordinatorLayout implements Snakba
67 70
             @Override
68 71
             public void run() {
69 72
                 if (fabParams != null) {
70
-                    if (layout.getCurrentScreen().getScreenInstanceId().equals(fabParams.screenInstanceId)) {
73
+                    Screen currentScreen = null;
74
+                    try {
75
+                        currentScreen = layout.getCurrentScreen();
76
+                    } catch(EmptyStackException exception) {
77
+                        currentScreen = null;
78
+                    }
79
+                    if (currentScreen != null && currentScreen.getScreenInstanceId().equals(fabParams.screenInstanceId)) {
71 80
                         fabCoordinator.add(fabParams);
72 81
                     }
73 82
                 }