List of usage examples for android.view MenuItem setVisible
public MenuItem setVisible(boolean visible);
From source file:com.github.shareme.gwsmaterialuikit.library.material.app.ToolbarManager.java
/** * This function should be called in onPrepareOptionsMenu(Menu) of Activity that use * Toolbar as ActionBar, or after inflating menu. *///from w w w . ja v a2 s. com public void onPrepareMenu() { if (mGroupChanged || mMenuDataChanged) { mToolbar.getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener); Menu menu = mToolbar.getMenu(); for (int i = 0, count = menu.size(); i < count; i++) { MenuItem item = menu.getItem(i); item.setVisible(item.getGroupId() == mCurrentGroup || item.getGroupId() == 0); } mMenuDataChanged = false; } }
From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java
private void showMenu(final boolean visible) { Menu menu = getMenu();/*from www. jav a 2s.c o m*/ for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (alwaysShowingMenu.contains(item.getItemId())) continue; item.setVisible(visible); } }
From source file:net.zorgblub.typhon.fragment.CatalogFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { Option<Feed> feed = adapter.getFeed(); boolean searchEnabled = !isEmpty(feed.flatMap(Feed::getSearchLink)); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); boolean enabled; switch (item.getItemId()) { case R.id.search: enabled = searchEnabled;//ww w. ja v a 2 s .c om break; default: enabled = true; } item.setEnabled(enabled); item.setVisible(enabled); } LOG.debug("Adapter has feed: " + adapter.getFeed()); }
From source file:com.google.android.apps.forscience.whistlepunk.project.ProjectDetailsFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { MenuItem archiveButton = menu.findItem(R.id.action_archive_project); MenuItem unarchiveButton = menu.findItem(R.id.action_unarchive_project); MenuItem deleteButton = menu.findItem(R.id.action_delete_project); // If the project hasn't loaded yet hide both options. if (mProject == null) { archiveButton.setVisible(false); unarchiveButton.setVisible(false); deleteButton.setVisible(false);//from w ww.ja v a2s . c o m } else { // Show the archive button if the project is not already archived. archiveButton.setVisible(!mProject.isArchived()); // Show the unarchive button if it's already archived. unarchiveButton.setVisible(mProject.isArchived()); deleteButton.setVisible(true); deleteButton.setEnabled(mProject.isArchived()); } MenuItem includeArchived = menu.findItem(R.id.action_include_archived); includeArchived.setChecked(mIncludeArchived); }
From source file:de.dreier.mytargets.features.statistics.StatisticsActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); final MenuItem filter = menu.findItem(R.id.action_filter); final MenuItem export = menu.findItem(R.id.action_export); filter.setIcon(showFilter ? R.drawable.ic_clear_filter_white_24dp : R.drawable.ic_filter_white_24dp); // only show filter if we have at least one category to filter by boolean filterAvailable = binding.distanceTags.getTags().size() > 1 || binding.diameterTags.getTags().size() > 1 || binding.bowTags.getTags().size() > 1 || binding.arrowTags.getTags().size() > 1; filter.setVisible(rounds != null && filterAvailable); export.setVisible(rounds != null);// w ww . j a va 2 s .c o m return true; }
From source file:com.bangz.smartmute.LocationsMapFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { Activity parentActivity = getActivity(); if (!(parentActivity instanceof BaseActivity && ((BaseActivity) parentActivity).isDrawerOpened())) { MenuItem discard = menu.findItem(R.id.action_discard); if (discard != null) { discard.setVisible(markerSelected != null && markerManager.getExtraInfo(markerSelected).getCollectionID() == MC_DATABASE); }/*from w ww.ja v a2 s. co m*/ } super.onPrepareOptionsMenu(menu); }
From source file:com.tct.mail.ui.ActionBarController.java
public boolean onPrepareOptionsMenu(Menu menu) { // We start out with every option enabled. Based on the current view, we disable actions // that are possible. LogUtils.d(LOG_TAG, "ActionBarView.onPrepareOptionsMenu()."); //[FEATURE]-Add-BEGIN by CDTS.zhonghua.tuo,05/21/2014,FR 670064 // TS: xiaolin.li 2014-11-25 EMAIL READ_PLF MOD_S //boolean searchEnhance = mContext.getResources().getBoolean(R.bool.feature_email_search_enhance_on); boolean searchEnhance = PLFUtils.getBoolean(mContext, "feature_email_search_enhance_on"); // TS: xiaolin.li 2014-11-25 EMAIL READ_PLF MOD_E if (mLocalSearchItem != null) { mLocalSearchItem/*from w ww .ja v a 2s . c o m*/ .setVisible(mAccount != null && mFolder != null && SERVICE_SEARCH_MODE && searchEnhance); } if (mServiceSearchItem != null) { mServiceSearchItem.setVisible(mAccount != null && mFolder != null && mAccount.supportsCapability(AccountCapabilities.SERVER_SEARCH) && !SERVICE_SEARCH_MODE && searchEnhance); } //[FEATURE]-Add-END by CDTS.zhonghua.tuo //TS: junwei-xu 2015-10-27 EMAIL BUGFIX-791734 MOD //NOTE: Check if mController is null if (mController != null && mController.shouldHideMenuItems()) { // Shortcut: hide all menu items if the drawer is shown final int size = menu.size(); for (int i = 0; i < size; i++) { final MenuItem item = menu.getItem(i); item.setVisible(false); } return false; } validateVolatileMenuOptionVisibility(); switch (getMode()) { case ViewMode.CONVERSATION: case ViewMode.SEARCH_RESULTS_CONVERSATION: // We update the ActionBar options when we are entering conversation view because // waiting for the AbstractConversationViewFragment to do it causes duplicate icons // to show up during the time between the conversation is selected and the fragment // is added. setConversationModeOptions(menu); break; case ViewMode.CONVERSATION_LIST: // Show search if the account supports it Utils.setMenuItemVisibility(menu, R.id.search, mAccount.supportsSearch());//[FEATURE]-Add-BEGIN by TSNJ Zhenhua.Fan,10/23/2014,PR 728378 //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 ADD-S // Hide star toggle if not support it updateStarToggleVisible(isExpandedSearch()); //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 ADD-E break; case ViewMode.SEARCH_RESULTS_LIST: // Hide compose and search Utils.setMenuItemVisibility(menu, R.id.compose, false); Utils.setMenuItemVisibility(menu, R.id.search, false); LogUtils.logFeature(LogTag.SEARCH_TAG, "EmailActionBarView onPrepareOptionsMenu SEARCH_RESULTS_LIST"); break; } return false; }
From source file:com.github.michalbednarski.intentslab.editor.IntentEditorActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); {//from w ww .j av a2 s. co m MenuItem runIntentOption = menu.findItem(R.id.menu_run_intent); if (mComponentType == IntentEditorConstants.RESULT) { if (getIntent().getBooleanExtra(EXTRA_FORWARD_ABLE_RESULT, false)) { runIntentOption.setVisible(true).setTitle("setResult(); finish()"); } else { runIntentOption.setVisible(false); } } else { runIntentOption.setVisible(true).setTitle( IntentGeneralFragment.getMethodNamesArray(getResources(), mComponentType)[mMethodId]); } } menu.findItem(R.id.set_editor_result).setVisible(mGenericEditorMode); menu.findItem(R.id.detach_intent_filter).setVisible(mAttachedIntentFilters != null); menu.findItem(R.id.component_info).setVisible(mEditedIntent.getComponent() != null); menu.findItem(R.id.attach_intent_filter).setVisible(mEditedIntent.getComponent() != null); // Intent tracking options { boolean intentTrackerAvailable = isIntentTrackerAvailable(); MenuItem trackIntentOption = menu.findItem(R.id.track_intent); trackIntentOption.setVisible(intentTrackerAvailable); trackIntentOption.setEnabled(intentTrackerAvailable); trackIntentOption.setChecked(getIntentTracker() != null); } // "Disable interception" option menu.findItem(R.id.disable_interception).setVisible(isInterceptedIntent()).setEnabled( isInterceptedIntent() && getPackageManager().getComponentEnabledSetting(new ComponentName(this, IntentEditorInterceptedActivity.class)) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED); return true; }
From source file:org.digitalcampus.oppia.activity.OppiaMobileActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { UIUtils.showUserData(menu, this, null); Menu drawerMenu = navigationView.getMenu(); MenuItem itemLogout = drawerMenu.findItem(R.id.menu_logout); MenuItem itemSettings = drawerMenu.findItem(R.id.menu_settings); MenuItem itemMonitor = drawerMenu.findItem(R.id.menu_monitor); MenuItem itemCourseDownload = drawerMenu.findItem(R.id.menu_download); itemLogout .setVisible(prefs.getBoolean(PrefsActivity.PREF_LOGOUT_ENABLED, MobileLearning.MENU_ALLOW_LOGOUT)); itemSettings.setVisible(MobileLearning.MENU_ALLOW_SETTINGS); itemMonitor.setVisible(MobileLearning.MENU_ALLOW_MONITOR); itemCourseDownload.setVisible(MobileLearning.MENU_ALLOW_COURSE_DOWNLOAD); return super.onPrepareOptionsMenu(menu); }
From source file:net.reichholf.dreamdroid.fragment.ServiceListFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { if (getMultiPaneHandler().isDrawerOpen()) return;//from w w w.j a va 2 s .c o m MenuItem setDefault = menu.findItem(R.id.menu_default); String defaultReference = DreamDroid.getCurrentProfile().getDefaultRef(); setDefault.setVisible(true); if (defaultReference != null) { if (defaultReference.equals(mDetailReference)) { setDefault.setIcon(R.drawable.ic_action_fav); setDefault.setTitle(R.string.reset_default); } else { setDefault.setIcon(R.drawable.ic_action_nofav); setDefault.setTitle(R.string.set_default); } } }