ソースを参照

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

Guy Carmeli 7 年 前
コミット
82e68cee70
共有1 個のファイルを変更した8 個の追加1 個の削除を含む
  1. 8
    1
      android/app/src/main/java/com/reactnativenavigation/layouts/BottomTabsLayout.java

+ 8
- 1
android/app/src/main/java/com/reactnativenavigation/layouts/BottomTabsLayout.java ファイルの表示

@@ -6,6 +6,7 @@ import android.support.annotation.NonNull;
6 6
 import android.support.annotation.Nullable;
7 7
 import android.support.v4.widget.DrawerLayout;
8 8
 import android.support.v7.app.AppCompatActivity;
9
+import android.util.Log;
9 10
 import android.view.View;
10 11
 import android.widget.RelativeLayout;
11 12
 
@@ -333,7 +334,13 @@ public class BottomTabsLayout extends BaseLayout implements AHBottomNavigation.O
333 334
     }
334 335
 
335 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 346
     private boolean hasBackgroundColor(StyleParams params) {