Java Code Examples for android.view.MenuItem.hasSubMenu()

The following are Jave code examples for showing how to use hasSubMenu() of the android.view.MenuItem class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: boohee_v5.6   File: MenuBuilder.java   View Source Code Vote up 7 votes
public void restoreActionViewStates(Bundle states) {
    if (states != null) {
        SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(getActionViewStatesKey());
        int itemCount = size();
        for (int i = 0; i < itemCount; i++) {
            MenuItem item = getItem(i);
            View v = MenuItemCompat.getActionView(item);
            if (!(v == null || v.getId() == -1)) {
                v.restoreHierarchyState(viewStates);
            }
            if (item.hasSubMenu()) {
                ((SubMenuBuilder) item.getSubMenu()).restoreActionViewStates(states);
            }
        }
        int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
        if (expandedId > 0) {
            MenuItem itemToExpand = findItem(expandedId);
            if (itemToExpand != null) {
                MenuItemCompat.expandActionView(itemToExpand);
            }
        }
    }
}
 
Example 2
Project: chromium-for-android-56-debug-video   File: AppMenuAdapter.java   View Source Code Vote up 6 votes
@Override
public int getItemViewType(int position) {
    MenuItem item = getItem(position);
    int viewCount = item.hasSubMenu() ? item.getSubMenu().size() : 1;

    if (item.getItemId() == R.id.update_menu_id) {
        return UPDATE_MENU_ITEM;
    } else if (viewCount == 5) {
        return FIVE_BUTTON_MENU_ITEM;
    } else if (viewCount == 4) {
        return FOUR_BUTTON_MENU_ITEM;
    } else if (viewCount == 3) {
        return THREE_BUTTON_MENU_ITEM;
    } else if (viewCount == 2) {
        return TITLE_BUTTON_MENU_ITEM;
    }
    return STANDARD_MENU_ITEM;
}
 
Example 3
Project: markor   File: ContextUtils.java   View Source Code Vote up 5 votes
public ContextUtils tintMenuItems(Menu menu, boolean recurse, @ColorInt int iconColor) {
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        tintDrawable(item.getIcon(), iconColor);
        if (item.hasSubMenu() && recurse) {
            tintMenuItems(item.getSubMenu(), recurse, iconColor);
        }
    }
    return this;
}
 
Example 4
Project: Quran   File: AyahToolBar.java   View Source Code Vote up 5 votes
@Override
public void onClick(View v) {
  final MenuItem item = menu.findItem(v.getId());
  if (item == null) return;
  if (item.hasSubMenu()) {
    showMenu(item.getSubMenu());
  } else if (itemSelectedListener != null) {
    itemSelectedListener.onMenuItemClick(item);
  }
}
 
Example 5
Project: memetastic   File: ContextUtils.java   View Source Code Vote up 5 votes
public ContextUtils tintMenuItems(Menu menu, boolean recurse, @ColorInt int iconColor) {
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        tintDrawable(item.getIcon(), iconColor);
        if (item.hasSubMenu() && recurse) {
            tintMenuItems(item.getSubMenu(), recurse, iconColor);
        }
    }
    return this;
}
 
Example 6
Project: letv   File: ShareCompat.java   View Source Code Vote up 4 votes
boolean shouldAddChooserIntent(MenuItem item) {
    return !item.hasSubMenu();
}
 
Example 7
Project: login   File: BottomSheetAdapterBuilder.java   View Source Code Vote up 4 votes
private List<BottomSheetItem> createAdapterItems(int dividerBackground, int titleTextColor,
                                                 int itemTextColor, int itemBackground,
                                                 int tintColor) {
    List<BottomSheetItem> items = new ArrayList<>();
    mTitles = 0;

    boolean addedSubMenu = false;

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

        if (item.isVisible()) {
            if (item.hasSubMenu()) {
                SubMenu subMenu = item.getSubMenu();

                if (i != 0 && addedSubMenu) {
                    if (mMode == BottomSheetBuilder.MODE_GRID) {
                        throw new IllegalArgumentException("MODE_GRID can't have submenus." +
                                " Use MODE_LIST instead");
                    }
                    items.add(new BottomSheetDivider(dividerBackground));
                }

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

                for (int j = 0; j < subMenu.size(); j++) {
                    MenuItem subItem = subMenu.getItem(j);
                    if (subItem.isVisible()) {
                        items.add(new BottomSheetMenuItem(subItem,itemTextColor, itemBackground, tintColor));
                        addedSubMenu = true;
                    }
                }
            } else {
                items.add(new BottomSheetMenuItem(item, itemTextColor, itemBackground, tintColor));
            }
        }
    }
    return items;
}
 
Example 8
Project: boohee_v5.6   File: ShareCompat.java   View Source Code Vote up 4 votes
boolean shouldAddChooserIntent(MenuItem item) {
    return !item.hasSubMenu();
}