Skip to content

Commit

Permalink
Add flag to disable FixedLayout's expand animation. Closes sephiroth7…
Browse files Browse the repository at this point in the history
  • Loading branch information
paolorotolo committed Jun 23, 2018
1 parent eb74422 commit e036821
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ public class BottomNavigation extends FrameLayout implements OnItemClickListener
*/
private boolean attached;


/**
* Set if current item should expand (default true)
*/
private boolean itemExpands = true;

private BadgeProvider badgeProvider;

public BottomNavigation(final Context context) {
Expand Down Expand Up @@ -630,7 +636,7 @@ private void initializeContainer(final MenuParser.Menu menu) {
} else if (menu.isShifting()) {
itemsContainer = new ShiftingLayout(getContext());
} else {
itemsContainer = new FixedLayout(getContext());
itemsContainer = new FixedLayout(getContext(), itemExpands);
}

// force the layout manager ID
Expand Down Expand Up @@ -849,6 +855,10 @@ static BadgeProvider parseBadgeProvider(final BottomNavigation navigation, final
}
}

public void setItemExpands(boolean itemExpands) {
this.itemExpands = itemExpands;
}

public interface OnMenuItemSelectionListener {
void onMenuItemSelect(@IdRes final int itemId, final int position, final boolean fromUser);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,25 @@ public class FixedLayout extends ViewGroup implements ItemsLayoutContainer {
OnItemClickListener listener;
private int itemFinalWidth;
private MenuParser.Menu menu;
private boolean itemExpands;


public FixedLayout(final Context context) {
super(context);
this.itemExpands = true;

totalChildrenSize = 0;
selectedIndex = 0;

final Resources res = getResources();
maxActiveItemWidth = res.getDimensionPixelSize(R.dimen.bbn_fixed_maxActiveItemWidth);
minActiveItemWidth = res.getDimensionPixelSize(R.dimen.bbn_fixed_minActiveItemWidth);
}

public FixedLayout(final Context context, boolean itemExpands) {
super(context);
this.itemExpands = itemExpands;

totalChildrenSize = 0;
selectedIndex = 0;

Expand Down Expand Up @@ -108,7 +124,7 @@ public void setSelectedIndex(final int index, final boolean animate) {
current.setExpanded(false, 0, animate);
}
if (null != child) {
child.setExpanded(true, 0, animate);
child.setExpanded(itemExpands, 0, animate);
}
}

Expand Down

0 comments on commit e036821

Please sign in to comment.