Skip to content

Commit e0a2237

Browse files
committed
-Add way to change bar programmatically without triggering listeners
1 parent 338ee86 commit e0a2237

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ public void selectTabAtPosition(int position) {
432432
* @param animate should the tab change be animated or not.
433433
*/
434434
public void selectTabAtPosition(int position, boolean animate) {
435+
selectTabAtPosition(position, animate, true);
436+
}
437+
438+
public void selectTabAtPosition(int position, boolean animate, boolean triggerListeners) {
435439
if (position > getTabCount() - 1 || position < 0) {
436440
throw new IndexOutOfBoundsException("Can't select tab at position " +
437441
position + ". This BottomBar has no items at that position.");
@@ -443,7 +447,11 @@ public void selectTabAtPosition(int position, boolean animate) {
443447
oldTab.deselect(animate);
444448
newTab.select(animate);
445449

446-
updateSelectedTab(position);
450+
if(triggerListeners)
451+
updateSelectedTab(position);
452+
else
453+
currentTabPosition = newPosition;
454+
447455
shiftingMagic(oldTab, newTab, animate);
448456
handleBackgroundColorChange(newTab, animate);
449457
}

0 commit comments

Comments
 (0)