List of usage examples for android.view Menu removeItem
public void removeItem(int id);
From source file:com.audiokernel.euphonyrmt.MainMenuActivity.java
void prepareNowPlayingMenu(final Menu menu) { final boolean isStreaming = mApp.isStreamActive(); final MPD mpd = mApp.oMPDAsyncHelper.oMPD; final MPDStatus mpdStatus = mpd.getStatus(); // Reminder : never disable buttons that are shown as actionbar actions here if (mpd.isConnected()) { if (menu.findItem(CONNECT) != null) { menu.removeItem(CONNECT); }//from w w w .j a va 2 s . c o m } else { if (menu.findItem(CONNECT) == null) { menu.add(0, CONNECT, 0, R.string.connect); } } final MenuItem saveItem = menu.findItem(R.id.PLM_Save); final MenuItem clearItem = menu.findItem(R.id.PLM_Clear); if (!mIsDualPaneMode && mNowPlayingPager != null && mNowPlayingPager.getCurrentItem() == 0) { saveItem.setVisible(false); clearItem.setVisible(false); } else { saveItem.setVisible(true); clearItem.setVisible(true); } /** If in streamingMode or persistentNotification don't allow a checkbox in the menu. */ final MenuItem notificationItem = menu.findItem(R.id.GMM_ShowNotification); if (notificationItem != null) { if (isStreaming || mApp.isNotificationPersistent()) { notificationItem.setVisible(false); } else { notificationItem.setVisible(true); } setMenuChecked(notificationItem, mApp.isNotificationActive()); } setMenuChecked(menu.findItem(R.id.GMM_Stream), isStreaming); setMenuChecked(menu.findItem(R.id.GMM_Single), mpdStatus.isSingle()); setMenuChecked(menu.findItem(R.id.GMM_Consume), mpdStatus.isConsume()); }
From source file:io.jawg.osmcontributor.ui.activities.MapActivity.java
@Subscribe(threadMode = ThreadMode.MAIN) public void onPleaseInitializeNoteDrawerEvent(PleaseInitializeNoteDrawerEvent event) { Menu menu = filterView.getMenu(); if (!FlavorUtils.isPoiStorage()) { displayOpenNotes = event.isDisplayOpenNotes(); displayClosedNotes = event.isDisplayClosedNotes(); menu.findItem(R.id.display_open_notes_item).setChecked(displayOpenNotes); menu.findItem(R.id.display_closed_notes_item).setChecked(displayClosedNotes); menu.findItem(R.id.display_yes_accessibility).setChecked(true); menu.findItem(R.id.display_limited_accessibility).setChecked(true); menu.findItem(R.id.display_no_accessibility).setChecked(true); menu.findItem(R.id.display_unknown_accessibility).setChecked(true); } else {/* ww w.j a va2 s. c o m*/ menu.removeItem(R.id.drawer_filter_notes_menu); } }
From source file:com.keylesspalace.tusky.AccountActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (!isSelf) { MenuItem follow = menu.findItem(R.id.action_follow); String title;/* w ww . jav a 2s . com*/ if (following) { title = getString(R.string.action_unfollow); } else { title = getString(R.string.action_follow); } follow.setTitle(title); MenuItem block = menu.findItem(R.id.action_block); if (blocking) { title = getString(R.string.action_unblock); } else { title = getString(R.string.action_block); } block.setTitle(title); MenuItem mute = menu.findItem(R.id.action_mute); if (muting) { title = getString(R.string.action_unmute); } else { title = getString(R.string.action_mute); } mute.setTitle(title); } else { // It shouldn't be possible to block or follow yourself. menu.removeItem(R.id.action_follow); menu.removeItem(R.id.action_block); menu.removeItem(R.id.action_mute); } return super.onPrepareOptionsMenu(menu); }
From source file:com.fa.mastodon.activity.AccountActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (!isSelf) { MenuItem follow = menu.findItem(R.id.action_follow); follow.setTitle(getFollowAction()); follow.setVisible(followState != FollowState.REQUESTED); MenuItem block = menu.findItem(R.id.action_block); String title;//from w w w. j a va 2s . c om if (blocking) { title = getString(R.string.action_unblock); } else { title = getString(R.string.action_block); } block.setTitle(title); MenuItem mute = menu.findItem(R.id.action_mute); if (muting) { title = getString(R.string.action_unmute); } else { title = getString(R.string.action_mute); } mute.setTitle(title); } else { // It shouldn't be possible to block or follow yourself. menu.removeItem(R.id.action_follow); menu.removeItem(R.id.action_block); menu.removeItem(R.id.action_mute); } return super.onPrepareOptionsMenu(menu); }
From source file:com.money.manager.ex.home.MainActivity.java
private void destroySyncToolbarItem(Menu menu) { if (menu == null) return;//from w w w. j av a2 s . c om int id = R.id.menuSyncProgress; if (menu.findItem(id) != null) { menu.removeItem(id); } if (mSyncMenuItem != null) { stopSyncIconRotation(mSyncMenuItem); mSyncMenuItem = null; } }
From source file:com.fastbootmobile.encore.app.MainActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { if (!mNavigationDrawerFragment.isDrawerOpen()) { if ((mCurrentFragmentIndex + 1) != SECTION_AUTOMIX) { // Only show items in the action bar relevant to this screen // if the drawer is not showing. Otherwise, let the drawer // decide what to show in the action bar. getMenuInflater().inflate(R.menu.main, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); mSearchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); mSearchView.setIconifiedByDefault(true); mSearchView.setQueryRefinementEnabled(true); mSearchView.setSubmitButtonEnabled(true); if (mCurrentFragmentIndex + 1 == SECTION_LISTEN_NOW) { menu.removeItem(R.id.action_search); }/*from w w w.j a v a 2 s. c o m*/ mSearchView.setOnSearchClickListener(new View.OnClickListener() { @Override public void onClick(View v) { menu.findItem(R.id.action_cast).setVisible(false); mNavigationDrawerFragment.setDrawerIndicatorEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mSearchView.requestFocus(); mToolbar.setBackgroundColor(getResources().getColor(R.color.primary)); } }); mSearchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { if (Utils.hasJellyBeanMR1()) { MenuItem item = menu.findItem(R.id.action_cast); if (item != null) { item.setVisible(true); } } getSupportActionBar().setDisplayHomeAsUpEnabled(false); mNavigationDrawerFragment.setDrawerIndicatorEnabled(true); return false; } }); // Setup cast button on 4.2+ MenuItem castMenu = menu.findItem(R.id.action_cast); if (Utils.hasJellyBeanMR1()) { MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat .getActionProvider(castMenu); mediaRouteActionProvider.setRouteSelector(mCastModule.getSelector()); castMenu.setVisible(true); } else { Log.w(TAG, "Api too low to show cast action"); castMenu.setVisible(false); } // Offline mode mOfflineMenuItem = menu.findItem(R.id.action_offline_mode); ProviderAggregator aggregator = ProviderAggregator.getDefault(); if (aggregator.hasNetworkConnectivity()) { mOfflineMenuItem.setChecked(aggregator.isOfflineMode()); } else { mOfflineMenuItem.setEnabled(false); } } restoreActionBar(); return true; } return super.onCreateOptionsMenu(menu); }
From source file:github.daneren2005.dsub.fragments.SelectDirectoryFragment.java
@Override public void onCreateContextMenu(Menu menu, MenuInflater menuInflater, UpdateView updateView, Entry entry) { onCreateContextMenuSupport(menu, menuInflater, updateView, entry); if (!entry.isVideo() && !Util.isOffline(context) && (playlistId == null || !playlistOwner) && (podcastId == null || Util.isOffline(context) && podcastId != null)) { menu.removeItem(R.id.song_menu_remove_playlist); }//from w w w. j a v a2s . c o m // Remove show artists if parent is not set and if not on a album list if ((albumListType == null || (entry.getParent() == null && entry.getArtistId() == null)) && !Util.isOffline(context)) { menu.removeItem(R.id.album_menu_show_artist); } if (podcastId != null && !Util.isOffline(context)) { if (UserUtil.canPodcast()) { String status = ((PodcastEpisode) entry).getStatus(); if ("completed".equals(status)) { menu.removeItem(R.id.song_menu_server_download); } } else { menu.removeItem(R.id.song_menu_server_download); menu.removeItem(R.id.song_menu_server_delete); } } recreateContextMenu(menu); }
From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java
@Override public void onCreateContextMenu(Menu menu, MenuInflater menuInflater, UpdateView updateView, Entry entry) { onCreateContextMenuSupport(menu, menuInflater, updateView, entry); if (!entry.isVideo() && !Util.isOffline(context) && (playlistId == null || !playlistOwner) && (podcastId == null || Util.isOffline(context) && podcastId != null)) { menu.removeItem(R.id.song_menu_remove_playlist); }// w w w . j a v a 2 s .c om recreateContextMenu(menu); }
From source file:github.daneren2005.dsub.fragments.SelectDirectoryFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { if (licenseValid == null) { menuInflater.inflate(R.menu.empty, menu); } else if (albumListType != null && !"starred".equals(albumListType)) { menuInflater.inflate(R.menu.select_album_list, menu); } else if (artist && !showAll) { menuInflater.inflate(R.menu.select_album, menu); if (!ServerInfo.hasTopSongs(context)) { menu.removeItem(R.id.menu_top_tracks); }// w ww .j a va 2 s . co m if (!ServerInfo.checkServerVersion(context, "1.11") || (id != null && "root".equals(id))) { menu.removeItem(R.id.menu_radio); menu.removeItem(R.id.menu_similar_artists); } else if (!ServerInfo.hasSimilarArtists(context)) { menu.removeItem(R.id.menu_similar_artists); } } else { if (podcastId == null) { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_song_offline, menu); } else { menuInflater.inflate(R.menu.select_song, menu); if (playlistId == null || !playlistOwner) { menu.removeItem(R.id.menu_remove_playlist); } } SharedPreferences prefs = Util.getPreferences(context); if (!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_NEXT, true)) { menu.setGroupVisible(R.id.hide_play_next, false); } if (!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_LAST, true)) { menu.setGroupVisible(R.id.hide_play_last, false); } } else { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_podcast_episode_offline, menu); } else { menuInflater.inflate(R.menu.select_podcast_episode, menu); if (!UserUtil.canPodcast()) { menu.removeItem(R.id.menu_download_all); } } } } if ("starred".equals(albumListType)) { menuInflater.inflate(R.menu.unstar, menu); } }
From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { if (licenseValid == null) { menuInflater.inflate(R.menu.empty, menu); } else if (albumListType != null && !"starred".equals(albumListType)) { menuInflater.inflate(R.menu.select_album_list, menu); } else if (artist && !showAll) { menuInflater.inflate(R.menu.select_album, menu); if (!ServerInfo.hasTopSongs(context)) { menu.removeItem(R.id.menu_top_tracks); }//from ww w . ja v a 2 s . c om if (!ServerInfo.checkServerVersion(context, "1.11")) { menu.removeItem(R.id.menu_radio); menu.removeItem(R.id.menu_similar_artists); } else if (!ServerInfo.hasSimilarArtists(context)) { menu.removeItem(R.id.menu_similar_artists); } } else { if (podcastId == null) { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_song_offline, menu); } else { menuInflater.inflate(R.menu.select_song, menu); if (playlistId == null || !playlistOwner) { menu.removeItem(R.id.menu_remove_playlist); } } SharedPreferences prefs = Util.getPreferences(context); if (!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_NEXT, true)) { menu.setGroupVisible(R.id.hide_play_next, false); } if (!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_LAST, true)) { menu.setGroupVisible(R.id.hide_play_last, false); } } else { if (Util.isOffline(context)) { menuInflater.inflate(R.menu.select_podcast_episode_offline, menu); } else { menuInflater.inflate(R.menu.select_podcast_episode, menu); if (!UserUtil.canPodcast()) { menu.removeItem(R.id.menu_download_all); } } } } if ("starred".equals(albumListType)) { menuInflater.inflate(R.menu.unstar, menu); } }