Skip to content

Commit

Permalink
Only add visible items
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensousa committed May 19, 2016
1 parent 834d722 commit e1dcfc4
Showing 1 changed file with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,24 +261,34 @@ private List<BottomSheetItem> createMenuItems() {
menu = mMenu;
}

boolean addedSubMenu = false;

for (int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);

if (item.hasSubMenu()) {
if (i != 0) {
items.add(new BottomSheetDivider(mDividerBackground));
}
CharSequence title = item.getTitle();
if (title != null && !title.equals("")) {
items.add(new BottomSheetHeader(title.toString(), mTitleTextColor));
}
SubMenu subMenu = item.getSubMenu();
for (int j = 0; j < subMenu.size(); j++) {
items.add(new BottomSheetMenuItem(subMenu.getItem(j),
mItemTextColor, mItemBackground));
if (item.isVisible()) {
if (item.hasSubMenu()) {
SubMenu subMenu = item.getSubMenu();

if (i != 0 && addedSubMenu) {
items.add(new BottomSheetDivider(mDividerBackground));
}

CharSequence title = item.getTitle();
if (title != null && !title.equals("")) {
items.add(new BottomSheetHeader(title.toString(), mTitleTextColor));
}

for (int j = 0; j < subMenu.size(); j++) {
MenuItem subItem = subMenu.getItem(j);
if (subItem.isVisible()) {
items.add(new BottomSheetMenuItem(subItem, mItemTextColor, mItemBackground));
addedSubMenu = true;
}
}
} else {
items.add(new BottomSheetMenuItem(item, mItemTextColor, mItemBackground));
}
} else {
items.add(new BottomSheetMenuItem(item, mItemTextColor, mItemBackground));
}
}

Expand Down

0 comments on commit e1dcfc4

Please sign in to comment.