Skip to content

Commit

Permalink
fix: Tab index out of number of tabs range
Browse files Browse the repository at this point in the history
  • Loading branch information
moonjava2005 committed Dec 12, 2023
1 parent 6e7e8f6 commit 6bfcf16
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,11 @@ public void selectTab(final int newIndex) {
}

private void selectTab(int newIndex, boolean enableSelectionHistory) {
saveTabSelection(newIndex, enableSelectionHistory);
tabsAttacher.onTabSelected(tabs.get(newIndex));
final int nextIndex = Math.max(0, Math.min(newIndex, tabs.size() - 1));
saveTabSelection(nextIndex, enableSelectionHistory);
tabsAttacher.onTabSelected(tabs.get(nextIndex));
getCurrentView().setVisibility(View.INVISIBLE);
bottomTabs.setCurrentItem(newIndex, false);
bottomTabs.setCurrentItem(nextIndex, false);
getCurrentView().setVisibility(View.VISIBLE);
getCurrentChild().onViewWillAppear();
getCurrentChild().onViewDidAppear();
Expand Down

0 comments on commit 6bfcf16

Please sign in to comment.