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
 import com.reactnativenavigation.layouts.Layout;
11
 import com.reactnativenavigation.layouts.Layout;
12
 import com.reactnativenavigation.params.FabParams;
12
 import com.reactnativenavigation.params.FabParams;
13
 import com.reactnativenavigation.params.SnackbarParams;
13
 import com.reactnativenavigation.params.SnackbarParams;
14
+import com.reactnativenavigation.screens.Screen;
15
+
16
+import java.util.EmptyStackException;
14
 
17
 
15
 public class SnackbarAndFabContainer extends CoordinatorLayout implements Snakbar.OnDismissListener, Subscriber{
18
 public class SnackbarAndFabContainer extends CoordinatorLayout implements Snakbar.OnDismissListener, Subscriber{
16
     private Snakbar snakbar;
19
     private Snakbar snakbar;
67
             @Override
70
             @Override
68
             public void run() {
71
             public void run() {
69
                 if (fabParams != null) {
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
                         fabCoordinator.add(fabParams);
80
                         fabCoordinator.add(fabParams);
72
                     }
81
                     }
73
                 }
82
                 }