List of usage examples for android.view Menu size
public int size();
From source file:com.github.jvanhie.discogsscrobbler.DrawerActivity.java
/*** * Called when invalidateOptionsMenu() is triggered *//*from w ww .ja v a2 s . co m*/ @Override public boolean onPrepareOptionsMenu(Menu menu) { // if nav drawer is opened, hide the action items boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList); for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setVisible(!drawerOpen); } return super.onPrepareOptionsMenu(menu); }
From source file:com.example.snapcacheexample.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // only add the menu when the selection fragment is showing if (fragments[SELECTION].isVisible()) { if (menu.size() == 0) { settings = menu.add(R.string.settings); }// w w w .j a va 2 s.c om return true; } else { menu.clear(); settings = null; } return false; }
From source file:org.mariotaku.twidere.util.ThemeUtils.java
public static void wrapToolbarMenuIcon(@Nullable ActionMenuView view, int itemColor, int popupItemColor, int... excludeGroups) { if (view == null) return;//from w w w .j ava2s .c om final Menu menu = view.getMenu(); final int childCount = view.getChildCount(); for (int i = 0, j = menu.size(), k = 0; i < j; i++) { final MenuItem item = menu.getItem(i); wrapMenuItemIcon(item, itemColor, excludeGroups); if (item.hasSubMenu()) { wrapMenuIcon(item.getSubMenu(), popupItemColor, popupItemColor, excludeGroups); } if (item.isVisible()) { k++; } } }
From source file:org.mariotaku.twidere.util.ThemeUtils.java
public static void wrapMenuIcon(ActionMenuView view, int colorDark, int colorLight, int... excludeGroups) { final int itemBackgroundColor = ThemeUtils.getThemeBackgroundColor(view.getContext()); final int popupItemBackgroundColor = ThemeUtils.getThemeBackgroundColor(view.getContext(), view.getPopupTheme());// w w w . jav a 2 s . c o m final int itemColor = TwidereColorUtils.getContrastYIQ(itemBackgroundColor, colorDark, colorLight); final int popupItemColor = TwidereColorUtils.getContrastYIQ(popupItemBackgroundColor, colorDark, colorLight); final Menu menu = view.getMenu(); final int childCount = view.getChildCount(); for (int i = 0, j = menu.size(), k = 0; i < j; i++) { final MenuItem item = menu.getItem(i); wrapMenuItemIcon(item, itemColor, excludeGroups); if (item.hasSubMenu()) { wrapMenuIcon(item.getSubMenu(), popupItemColor, popupItemColor, excludeGroups); } if (item.isVisible()) { k++; } } }
From source file:com.doplgangr.secrecy.views.MainActivity.java
private void hideMenuItems(Menu menu, boolean visible) { for (int i = 0; i < menu.size(); i++) menu.getItem(i).setVisible(visible); }
From source file:com.todoroo.astrid.actfm.CommentsFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (menu.size() > 0) { return;/*from ww w . j av a 2 s . c o m*/ } MenuItem item; boolean showCommentsRefresh = false; if (showCommentsRefresh) { Activity activity = getActivity(); if (activity instanceof TaskListActivity) { TaskListActivity tla = (TaskListActivity) activity; showCommentsRefresh = tla.getTaskEditFragment() == null; } } if (showCommentsRefresh) { item = menu.add(Menu.NONE, MENU_REFRESH_ID, Menu.NONE, R.string.ENA_refresh_comments); item.setIcon(R.drawable.icn_menu_refresh_dark); } }
From source file:com.android.screenspeak.contextmenu.RadialMenuManager.java
/** * Plays an F# harmonic minor scale with a number of notes equal to the number of items in the * specified menu, up to 8 notes.//from w ww . j av a 2s.c om * * @param menu to play scale for */ private void playScaleForMenu(Menu menu) { final int size = menu.size(); if (size <= 0) { return; } mFeedbackController.playAuditory(SCALES[Math.min(size - 1, 7)]); }
From source file:com.jefftharris.passwdsafe.PasswdSafeNavDrawerFragment.java
/** * Update drawer for the fragments displayed in the activity * @param fileNameUpdate If non-null, the file name to set in the view *//* w w w .j a va 2s.c o m*/ public void updateView(Mode mode, String fileNameUpdate, boolean fileOpen) { boolean drawerEnabled = false; boolean openDrawer = false; int upIndicator = 0; NavMenuItem selNavItem = null; switch (mode) { case INIT: { drawerEnabled = true; break; } case RECORDS_LIST: { drawerEnabled = true; // If the user hasn't 'learned' about the drawer, open it openDrawer = shouldOpenDrawer(); selNavItem = NavMenuItem.RECORDS; break; } case RECORDS_SINGLE: { selNavItem = NavMenuItem.RECORDS; break; } case RECORDS_ACTION: { upIndicator = R.drawable.ic_action_close_cancel; selNavItem = NavMenuItem.RECORDS; break; } case POLICIES: { drawerEnabled = true; selNavItem = NavMenuItem.PASSWORD_POLICIES; break; } case EXPIRATIONS: { drawerEnabled = true; selNavItem = NavMenuItem.EXPIRED_PASSWORDS; break; } case PREFERENCES: { drawerEnabled = true; selNavItem = NavMenuItem.PREFERENCES; break; } case ABOUT: { drawerEnabled = true; selNavItem = NavMenuItem.ABOUT; break; } } updateDrawerToggle(drawerEnabled, upIndicator); Menu menu = getNavView().getMenu(); for (int i = 0; i < menu.size(); ++i) { MenuItem item = menu.getItem(i); int itemId = item.getItemId(); if (selNavItem == null) { item.setChecked(false); } else if (selNavItem.itsMenuId == itemId) { item.setChecked(true); } if ((itemId == NavMenuItem.RECORDS.itsMenuId) || (itemId == NavMenuItem.PASSWORD_POLICIES.itsMenuId) || (itemId == NavMenuItem.EXPIRED_PASSWORDS.itsMenuId)) { item.setEnabled(fileOpen); } } itsSelNavItem = selNavItem; if (fileNameUpdate != null) { GuiUtils.setVisible(itsFileName, !TextUtils.isEmpty(fileNameUpdate)); itsFileName.setText(fileNameUpdate); } openDrawer(openDrawer); }
From source file:com.shafiq.mytwittle.view.TweetSpotlightActivity.java
void storeMenuItems(Menu menu) { for (int i = 0; i < menu.size(); i++) { MenuItem menuItem = menu.getItem(i); if (menuItem.getItemId() == R.id.action_favorite) { mFavoriteMenuItem = menuItem; boolean isDarkTheme = AppSettings.get().getCurrentTheme() == AppSettings.Theme.Holo_Dark; if (mStatus.mIsFavorited == true) { mFavoriteMenuItem.setIcon( isDarkTheme ? R.drawable.ic_action_star_on_dark : R.drawable.ic_action_star_on_light); mFavoriteMenuItem.setTitle(R.string.action_unfavorite); } else { mFavoriteMenuItem.setIcon( isDarkTheme ? R.drawable.ic_action_star_off_dark : R.drawable.ic_action_star_off_light); mFavoriteMenuItem.setTitle(R.string.action_favorite); }//from w ww .j a v a2 s. c o m break; } } }
From source file:com.notriddle.budget.EnvelopesActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { boolean drawerOpen = mDrawerLayout.isDrawerOpen(mNavDrawer); int l = menu.size(); for (int i = 0; i != l; ++i) { menu.getItem(i).setVisible(!drawerOpen); }/*from w w w. j av a 2 s.c o m*/ return super.onPrepareOptionsMenu(menu); }