Browse Source

Don't crash when selecting BottomTab by navigatorId if ScreenStack was not found

Guy Carmeli 7 years ago
parent
commit
82e68cee70

+ 8
- 1
android/app/src/main/java/com/reactnativenavigation/layouts/BottomTabsLayout.java View File

6
 import android.support.annotation.Nullable;
6
 import android.support.annotation.Nullable;
7
 import android.support.v4.widget.DrawerLayout;
7
 import android.support.v4.widget.DrawerLayout;
8
 import android.support.v7.app.AppCompatActivity;
8
 import android.support.v7.app.AppCompatActivity;
9
+import android.util.Log;
9
 import android.view.View;
10
 import android.view.View;
10
 import android.widget.RelativeLayout;
11
 import android.widget.RelativeLayout;
11
 
12
 
333
     }
334
     }
334
 
335
 
335
     public void selectBottomTabByNavigatorId(String navigatorId) {
336
     public void selectBottomTabByNavigatorId(String navigatorId) {
336
-        bottomTabs.setCurrentItem(getScreenStackIndex(navigatorId));
337
+        try {
338
+            bottomTabs.setCurrentItem(getScreenStackIndex(navigatorId));
339
+        } catch (ScreenStackNotFoundException e) {
340
+            Log.e("BottomTabsLayout", "Could not select bottom tab by navigatorId [" + navigatorId + "]." +
341
+                                      "This should not have happened, it probably means navigator.switchToTab()" +
342
+                                      "was called from an unmounted tab.");
343
+        }
337
     }
344
     }
338
 
345
 
339
     private boolean hasBackgroundColor(StyleParams params) {
346
     private boolean hasBackgroundColor(StyleParams params) {