List of usage examples for android.view Menu removeItem
public void removeItem(int id);
From source file:com.fastbootmobile.encore.utils.Utils.java
public static void showSongOverflow(final FragmentActivity context, final View parent, final Song song, final boolean hideArtist) { PopupMenu popupMenu = new PopupMenu(context, parent); popupMenu.inflate(R.menu.track_overflow); if (song.getArtist() == null || hideArtist) { // This song has no artist information, hide the entry Menu menu = popupMenu.getMenu(); menu.removeItem(R.id.menu_open_artist); }/*w w w .j a va2 s. c o m*/ if (song.getAlbum() == null) { // This song has no album information, hide the entry Menu menu = popupMenu.getMenu(); menu.removeItem(R.id.menu_add_album_to_queue); } popupMenu.show(); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { final ProviderAggregator aggregator = ProviderAggregator.getDefault(); switch (menuItem.getItemId()) { case R.id.menu_play_now: PlaybackProxy.playSong(song); break; case R.id.menu_play_next: PlaybackProxy.playNext(song); break; case R.id.menu_open_artist: Intent intent = ArtistActivity.craftIntent(context, null, song.getArtist(), song.getProvider(), context.getResources().getColor(R.color.default_album_art_background)); context.startActivity(intent); break; case R.id.menu_add_to_queue: PlaybackProxy.queueSong(song, false); Toast.makeText(context, R.string.toast_song_added_to_queue, Toast.LENGTH_SHORT).show(); break; case R.id.menu_add_album_to_queue: PlaybackProxy.queueAlbum(aggregator.retrieveAlbum(song.getAlbum(), song.getProvider()), false); Toast.makeText(context, R.string.toast_album_added_to_queue, Toast.LENGTH_SHORT).show(); break; case R.id.menu_add_to_playlist: PlaylistChooserFragment fragment = PlaylistChooserFragment.newInstance(song); fragment.show(context.getSupportFragmentManager(), song.getRef()); break; default: return false; } return true; } }); }
From source file:com.fastbootmobile.encore.utils.Utils.java
public static void showCurrentSongOverflow(final Context context, final View parent, final Song song, final boolean showArtist) { PopupMenu popupMenu = new PopupMenu(context, parent); popupMenu.inflate(R.menu.queue_overflow); if (song.getAlbum() == null) { Log.d(TAG, "No album information, removing album options"); // This song has no album information, hide the entries Menu menu = popupMenu.getMenu(); menu.removeItem(R.id.menu_add_album_to_queue); menu.removeItem(R.id.menu_open_album); }//from ww w .jav a 2s. c o m if (!showArtist) { Menu menu = popupMenu.getMenu(); menu.removeItem(R.id.menu_open_artist); } popupMenu.show(); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { final ProviderAggregator aggregator = ProviderAggregator.getDefault(); switch (menuItem.getItemId()) { case R.id.menu_open_album: final Resources res = context.getResources(); Intent intent = AlbumActivity.craftIntent(context, ((BitmapDrawable) res.getDrawable(R.drawable.album_placeholder)).getBitmap(), song.getAlbum(), song.getProvider(), res.getColor(R.color.default_album_art_background)); context.startActivity(intent); break; case R.id.menu_open_artist: intent = ArtistActivity.craftIntent(context, null, song.getArtist(), song.getProvider(), context.getResources().getColor(R.color.default_album_art_background)); context.startActivity(intent); break; case R.id.menu_add_album_to_queue: PlaybackProxy.queueAlbum(aggregator.retrieveAlbum(song.getAlbum(), song.getProvider()), false); Toast.makeText(context, R.string.toast_album_added_to_queue, Toast.LENGTH_SHORT).show(); break; case R.id.menu_add_to_playlist: PlaylistChooserFragment fragment = PlaylistChooserFragment.newInstance(song); if (context instanceof FragmentActivity) { FragmentActivity act = (FragmentActivity) context; fragment.show(act.getSupportFragmentManager(), song.getRef()); } else { throw new IllegalArgumentException("Context must be an instance of FragmentActivity"); } break; default: return false; } return true; } }); }
From source file:com.oceansky.yellow.utils.Utils.java
public static void showSongOverflow(final FragmentActivity context, final View parent, final Song song, final boolean hideArtist) { if (song == null) { return;/* w ww . j av a 2s. c o m*/ } PopupMenu popupMenu = new PopupMenu(context, parent); popupMenu.inflate(R.menu.track_overflow); if (song.getArtist() == null || hideArtist) { // This song has no artist information, hide the entry Menu menu = popupMenu.getMenu(); menu.removeItem(R.id.menu_open_artist); } if (song.getAlbum() == null) { // This song has no album information, hide the entry Menu menu = popupMenu.getMenu(); menu.removeItem(R.id.menu_add_album_to_queue); } popupMenu.show(); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { final ProviderAggregator aggregator = ProviderAggregator.getDefault(); switch (menuItem.getItemId()) { case R.id.menu_play_now: PlaybackProxy.playSong(song); break; case R.id.menu_play_next: PlaybackProxy.playNext(song); break; case R.id.menu_open_artist: Intent intent = ArtistActivity.craftIntent(context, null, song.getArtist(), song.getProvider(), context.getResources().getColor(R.color.default_album_art_background)); context.startActivity(intent); break; case R.id.menu_add_to_queue: PlaybackProxy.queueSong(song, false); Toast.makeText(context, R.string.toast_song_added_to_queue, Toast.LENGTH_SHORT).show(); break; case R.id.menu_add_album_to_queue: PlaybackProxy.queueAlbum(aggregator.retrieveAlbum(song.getAlbum(), song.getProvider()), false); Toast.makeText(context, R.string.toast_album_added_to_queue, Toast.LENGTH_SHORT).show(); break; case R.id.menu_add_to_playlist: PlaylistChooserFragment fragment = PlaylistChooserFragment.newInstance(song); fragment.show(context.getSupportFragmentManager(), song.getRef()); break; default: return false; } return true; } }); }
From source file:com.teamcanjica.settings.device.AboutActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.removeItem(R.id.action_about); return true; }
From source file:co.nerdart.ourss.activity.EntriesListActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.removeItem(R.id.menu_refresh); // We do not want the refresh option here return true;/* ww w .ja v a 2 s.c o m*/ }
From source file:com.racoon.ampdroid.views.SettingsView.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (menu != null) { menu.removeItem(R.id.search); }//from w w w . j a va2 s . co m }
From source file:org.melky.geekjuniorapp.LicenseGeekFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); if (menu.hasVisibleItems()) menu.removeItem(menu.getItem(0).getItemId()); }
From source file:com.gh4a.activities.CommitActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.download_menu, menu); menu.removeItem(R.id.download); menu.removeItem(R.id.search);/*from ww w . j a v a2 s.c om*/ menu.removeItem(R.id.wrap); return super.onCreateOptionsMenu(menu); }
From source file:com.itime.team.itime.fragments.CalendarTypeSubFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // this fragment utilizes the same menu in container activity menu.removeItem(R.id.action_add); inflater.inflate(R.menu.calendar_type_sub, menu); }
From source file:com.gh4a.activities.GistViewerActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.download_menu, menu); menu.removeItem(R.id.download); menu.removeItem(R.id.share);/*from w w w. j av a 2s . c om*/ if (mGistFile == null) { menu.removeItem(R.id.browser); } return super.onCreateOptionsMenu(menu); }