List of usage examples for android.view MenuItem getGroupId
public int getGroupId();
From source file:com.google.android.apps.forscience.whistlepunk.MainActivity.java
@Override public boolean onNavigationItemSelected(MenuItem menuItem) { if (menuItem == null) { return false; }/*www . j av a 2s . c o m*/ if (menuItem.getGroupId() == R.id.navigation_top) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); Fragment fragment; int itemId = menuItem.getItemId(); final String tag = String.valueOf(itemId); fragment = getFragmentManager().findFragmentByTag(tag); if (fragment == null) { fragment = createNewFragment(itemId); } adjustActivityForSelectedItem(itemId); mTitleToRestore = getTitleToRestore(menuItem); transaction.replace(R.id.content_container, fragment, tag).commit(); if (menuItem.isCheckable()) { menuItem.setChecked(true); } mDrawerLayout.closeDrawers(); restoreActionBar(); mSelectedItemId = itemId; } else if (menuItem.getGroupId() == R.id.navigation_bottom) { mDrawerLayout.closeDrawers(); // Launch intents Intent intent = null; int itemId = menuItem.getItemId(); if (itemId == R.id.navigation_item_website) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.website_url))); } else if (itemId == R.id.navigation_item_settings) { intent = SettingsActivity.getLaunchIntent(this, menuItem.getTitle(), SettingsActivity.TYPE_SETTINGS); } else if (itemId == R.id.navigation_item_about) { intent = SettingsActivity.getLaunchIntent(this, menuItem.getTitle(), SettingsActivity.TYPE_ABOUT); } else if (itemId == R.id.dev_testing_options) { intent = SettingsActivity.getLaunchIntent(this, menuItem.getTitle(), SettingsActivity.TYPE_DEV_OPTIONS); } else if (itemId == R.id.navigation_item_feedback) { mFeedbackProvider.sendFeedback(new LoggingConsumer<Boolean>(TAG, "Send feedback") { @Override public void success(Boolean value) { if (!value) { showFeedbackError(); } } @Override public void fail(Exception e) { super.fail(e); showFeedbackError(); } }); } if (intent != null) { startActivity(intent); } } return false; }
From source file:ru.mtuci.musicanalyzer.apollo.ui.fragments.AlbumFragment.java
/** * {@inheritDoc}/* ww w . j ava 2 s . c o m*/ */ @Override public boolean onContextItemSelected(final MenuItem item) { // Avoid leaking context menu selections if (item.getGroupId() == GROUP_ID) { switch (item.getItemId()) { case FragmentMenuItems.PLAY_SELECTION: MusicUtils.playAll(getActivity(), mAlbumList, 0, false); return true; case FragmentMenuItems.ADD_TO_QUEUE: MusicUtils.addToQueue(getActivity(), mAlbumList); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(mAlbumList).show(getFragmentManager(), "CreatePlaylist"); return true; case FragmentMenuItems.MORE_BY_ARTIST: NavUtils.openArtistProfile(getActivity(), mAlbum.mArtistName); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final long id = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(getActivity(), mAlbumList, id); return true; case FragmentMenuItems.DELETE: mShouldRefresh = true; final String album = mAlbum.mAlbumName; DeleteDialog.newInstance(album, mAlbumList, album + Config.ALBUM_ART_SUFFIX) .show(getFragmentManager(), "DeleteDialog"); return true; default: break; } } return super.onContextItemSelected(item); }
From source file:com.andrew.apollo.ui.fragments.AlbumFragment.java
/** * {@inheritDoc}// www . j a va 2 s. co m */ @Override public boolean onContextItemSelected(final MenuItem item) { // Avoid leaking context menu selections if (item.getGroupId() == GROUP_ID) { switch (item.getItemId()) { case FragmentMenuItems.PLAY_SELECTION: MusicUtils.playAll(getSherlockActivity(), mAlbumList, 0, false); return true; case FragmentMenuItems.ADD_TO_QUEUE: MusicUtils.addToQueue(getSherlockActivity(), mAlbumList); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(mAlbumList).show(getFragmentManager(), "CreatePlaylist"); return true; case FragmentMenuItems.MORE_BY_ARTIST: NavUtils.openArtistProfile(getSherlockActivity(), mAlbum.mArtistName); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final long id = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(getSherlockActivity(), mAlbumList, id); return true; case FragmentMenuItems.DELETE: mShouldRefresh = true; final String album = mAlbum.mAlbumName; DeleteDialog.newInstance(album, mAlbumList, album + Config.ALBUM_ART_SUFFIX) .show(getFragmentManager(), "DeleteDialog"); return true; default: break; } } return super.onContextItemSelected(item); }
From source file:com.guayaba.tapir.ui.fragments.AlbumFragment.java
/** * {@inheritDoc}//from w ww . j av a2 s. co m */ @Override public boolean onContextItemSelected(final MenuItem item) { // Avoid leaking context menu selections if (item.getGroupId() == GROUP_ID) { switch (item.getItemId()) { case FragmentMenuItems.PLAY_SELECTION: MusicUtils.playAll(getActivity(), mAlbumList, 0, false); return true; case FragmentMenuItems.ADD_TO_QUEUE: MusicUtils.addToQueue(getActivity(), mAlbumList); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(mAlbumList).show(getFragmentManager(), "CreatePlaylist"); return true; case FragmentMenuItems.MORE_BY_ARTIST: NavUtils.openArtistProfile(getActivity(), mAlbum.mArtistName); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final long id = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(getActivity(), mAlbumList, id); return true; case FragmentMenuItems.DELETE: mShouldRefresh = true; final String album = mAlbum.mAlbumName; DeleteDialog .newInstance(album, mAlbumList, ImageFetcher.generateAlbumCacheKey(album, mAlbum.mArtistName)) .show(getFragmentManager(), "DeleteDialog"); return true; default: break; } } return super.onContextItemSelected(item); }
From source file:com.guayaba.tapir.ui.fragments.ArtistFragment.java
/** * {@inheritDoc}/*from ww w . j a v a 2s. c o m*/ */ @Override public boolean onContextItemSelected(final android.view.MenuItem item) { // Avoid leaking context menu selections if (item.getGroupId() == GROUP_ID) { switch (item.getItemId()) { case FragmentMenuItems.PLAY_SELECTION: MusicUtils.playAll(getActivity(), mArtistList, 0, true); return true; case FragmentMenuItems.ADD_TO_QUEUE: MusicUtils.addToQueue(getActivity(), mArtistList); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(mArtistList).show(getFragmentManager(), "CreatePlaylist"); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final long id = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(getActivity(), mArtistList, id); return true; case FragmentMenuItems.DELETE: mShouldRefresh = true; final String artist = mArtist.mArtistName; DeleteDialog.newInstance(artist, mArtistList, artist).show(getFragmentManager(), "DeleteDialog"); return true; default: break; } } return super.onContextItemSelected(item); }
From source file:com.boko.vimusic.ui.fragments.AlbumFragment.java
/** * {@inheritDoc}//from www .j a va2 s . co m */ @Override public boolean onContextItemSelected(final MenuItem item) { // Avoid leaking context menu selections if (item.getGroupId() == GROUP_ID) { switch (item.getItemId()) { case FragmentMenuItems.PLAY_SELECTION: MusicUtils.playAll(getActivity(), mAlbumList, 0, false); return true; case FragmentMenuItems.ADD_TO_QUEUE: MusicUtils.addToQueue(getActivity(), mAlbumList); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(mAlbumList).show(getFragmentManager(), "CreatePlaylist"); return true; case FragmentMenuItems.MORE_BY_ARTIST: NavUtils.openArtistProfile(getActivity(), mAlbum.mArtistName); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final String id = item.getIntent().getStringExtra("playlist"); MusicUtils.addToPlaylist(getActivity(), mAlbumList, id); return true; case FragmentMenuItems.DELETE: mShouldRefresh = true; final String album = mAlbum.getName(); DeleteDialog .newInstance(album, mAlbumList, ImageFetcher.generateAlbumCacheKey(album, mAlbum.mArtistName)) .show(getFragmentManager(), "DeleteDialog"); return true; default: break; } } return super.onContextItemSelected(item); }
From source file:com.boko.vimusic.ui.fragments.ArtistFragment.java
/** * {@inheritDoc}//from w ww . j a va 2 s. c o m */ @Override public boolean onContextItemSelected(final android.view.MenuItem item) { // Avoid leaking context menu selections if (item.getGroupId() == GROUP_ID) { switch (item.getItemId()) { case FragmentMenuItems.PLAY_SELECTION: MusicUtils.playAll(getActivity(), mArtistList, 0, true); return true; case FragmentMenuItems.ADD_TO_QUEUE: MusicUtils.addToQueue(getActivity(), mArtistList); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(mArtistList).show(getFragmentManager(), "CreatePlaylist"); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final String id = item.getIntent().getStringExtra("playlist"); MusicUtils.addToPlaylist(getActivity(), mArtistList, id); return true; case FragmentMenuItems.DELETE: mShouldRefresh = true; final String artist = mArtist.getName(); DeleteDialog.newInstance(artist, mArtistList, artist).show(getFragmentManager(), "DeleteDialog"); return true; default: break; } } return super.onContextItemSelected(item); }
From source file:com.andrew.apollo.ui.fragments.ArtistFragment.java
/** * {@inheritDoc}/*from w w w . j a v a 2 s .co m*/ */ @Override public boolean onContextItemSelected(final android.view.MenuItem item) { // Avoid leaking context menu selections if (item.getGroupId() == GROUP_ID) { switch (item.getItemId()) { case FragmentMenuItems.PLAY_SELECTION: MusicUtils.playAll(getSherlockActivity(), mArtistList, 0, true); return true; case FragmentMenuItems.ADD_TO_QUEUE: MusicUtils.addToQueue(getSherlockActivity(), mArtistList); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(mArtistList).show(getFragmentManager(), "CreatePlaylist"); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final long id = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(getSherlockActivity(), mArtistList, id); return true; case FragmentMenuItems.DELETE: mShouldRefresh = true; final String artist = mArtist.mArtistName; DeleteDialog.newInstance(artist, mArtistList, artist).show(getFragmentManager(), "DeleteDialog"); return true; default: break; } } return super.onContextItemSelected(item); }
From source file:com.irateam.vkplayer.activities.ListActivity.java
@Override public boolean onNavigationItemSelected(MenuItem menuItem) { drawerLayout.closeDrawers();//w w w .j av a2 s . c o m if (menuItem.getGroupId() == R.id.audio_group) { if (searchView != null) { searchView.post(() -> MenuItemCompat.collapseActionView(toolbarMenu.findItem(R.id.action_search))); } getSupportActionBar().setTitle(menuItem.getTitle()); refreshLayout.setRefreshing(true); } if (menuItem.getItemId() == R.id.cached_audio && cacheUpdateReceiver == null) { cacheUpdateReceiver = new DownloadFinishedReceiver() { @Override public void onDownloadFinished(Audio audio) { audioAdapter.getList().add(0, audio); audioAdapter.notifyDataSetChanged(); } }; registerReceiver(cacheUpdateReceiver, new IntentFilter(DownloadService.DOWNLOAD_FINISHED)); } else if (cacheUpdateReceiver != null) { unregisterReceiver(cacheUpdateReceiver); cacheUpdateReceiver = null; } switch (menuItem.getItemId()) { case R.id.current_playlist: audioService.getCurrentAudio(); return true; case R.id.my_audio: audioService.getMyAudio(); return true; case R.id.recommended_audio: audioService.getRecommendationAudio(); return true; case R.id.popular_audio: audioService.getPopularAudio(); return true; case R.id.cached_audio: audioService.getCachedAudio(); return true; case R.id.settings: startActivity(new Intent(this, SettingsActivity.class)); return true; case R.id.exit: VkLogout(); return true; } return false; }
From source file:com.audiokernel.euphonyrmt.fragments.BrowseFragment.java
@Override public boolean onMenuItemClick(final MenuItem item) { switch (item.getGroupId()) { case ADD_REPLACE_PLAY: case ADD_REPLACE: case ADD:/*from www . j ava 2 s. c o m*/ case ADD_PLAY: addAndReplace(item); break; case ADD_TO_PLAYLIST: addToPlaylist(item); break; case GOTO_ARTIST: final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); final Object selectedItem = mItems.get((int) info.id); final Intent intent = new Intent(getActivity(), SimpleLibraryActivity.class); Artist artist = null; if (selectedItem instanceof Album) { artist = ((AbstractAlbum) selectedItem).getArtist(); } else if (selectedItem instanceof Artist) { artist = (Artist) selectedItem; } else if (selectedItem instanceof Music) { artist = new Artist(((AbstractMusic) selectedItem).getAlbumArtistOrArtist()); } if (artist != null) { intent.putExtra("artist", artist); startActivityForResult(intent, -1); } break; default: final String name = item.getTitle().toString(); final int id = item.getOrder(); mApp.oMPDAsyncHelper.execAsync(new Runnable() { @Override public void run() { add(mItems.get(id), name); } }); break; } return false; }