Skip to content

Commit

Permalink
fix(android): guard for tab counts limit for bottom style (#11149)
Browse files Browse the repository at this point in the history
Fixes TIMOB-27302
  • Loading branch information
ypbnv authored and sgtcoolguy committed Sep 9, 2019
1 parent 6ffd9d4 commit 6a2aa4d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Expand Up @@ -126,7 +126,7 @@ public abstract class TiUIAbstractTabGroup extends TiUIView
public abstract String getTabTitle(int index);

// region protected fields
protected static final String TAG = "TiUITabLayoutTabGroup";
protected final static String TAG = "TiUIAbstractTabGroup";
protected static final String WARNING_LAYOUT_MESSAGE =
"Trying to customize an unknown layout, sticking to the default one";

Expand Down Expand Up @@ -237,7 +237,6 @@ public void addTab(TabProxy tabProxy)
tabFragmentIDs.add(fragmentIdGenerator.getAndIncrement());

this.tabGroupPagerAdapter.notifyDataSetChanged();

addTabItemInController(tabProxy);
}

Expand Down
Expand Up @@ -28,6 +28,7 @@
import java.util.ArrayList;

import ti.modules.titanium.ui.TabGroupProxy;
import ti.modules.titanium.ui.TabProxy;

/**
* TabGroup implementation using BottomNavigationView as a controller.
Expand All @@ -48,6 +49,22 @@ public TiUIBottomNavigationTabGroup(TabGroupProxy proxy, TiBaseActivity activity
super(proxy, activity);
}

// Overriding addTab method to provide a proper guard for trying to add more tabs than the limit
// for BottomNavigationView class.
@Override
public void addTab(TabProxy tabProxy)
{
if (this.mBottomNavigationView == null) {
return;
}
final int MAX_TABS = this.mBottomNavigationView.getMaxItemCount();
if (this.tabs.size() < MAX_TABS) {
super.addTab(tabProxy);
} else {
Log.w(TAG, "Bottom style TabGroup cannot have more than " + MAX_TABS + " tabs.");
}
}

@Override
public void addViews(TiBaseActivity activity)
{
Expand Down

0 comments on commit 6a2aa4d

Please sign in to comment.