List of usage examples for android.view MenuItem getGroupId
public int getGroupId();
From source file:com.github.kanata3249.ffxieq.android.FoodSelectorActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { FoodListView flv = (FoodListView) findViewById(R.id.ListView); if (item.getGroupId() == R.id.FilterByType) { if (item.getItemId() < 0) { mFilterByType = ""; } else {/* w w w . j av a2s . c om*/ mFilterByType = (String) item.getTitle(); } flv.setFilterByType(mFilterByType); return true; } switch (item.getItemId()) { case R.id.Remove: Intent result = new Intent(); result.putExtra("From", "FoodSelector"); result.putExtra("Id", -1); setResult(RESULT_OK, result); finish(); return true; case R.id.Filter: showDialog(0); return true; case R.id.ResetFilter: if (flv != null) { flv.setFilter(""); } mFilterID = -1; return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.guayaba.tapir.ui.fragments.QueueFragment.java
/** * {@inheritDoc}//from w ww . ja va 2s.c o m */ @Override public boolean onContextItemSelected(final android.view.MenuItem item) { if (item.getGroupId() == GROUP_ID) { switch (item.getItemId()) { case FragmentMenuItems.PLAY_NEXT: NowPlayingCursor queue = (NowPlayingCursor) QueueLoader.makeQueueCursor(getActivity()); queue.removeItem(mSelectedPosition); queue.close(); queue = null; MusicUtils.playNext(new long[] { mSelectedId }); refreshQueue(); return true; case FragmentMenuItems.REMOVE_FROM_QUEUE: MusicUtils.removeTrack(mSelectedId); refreshQueue(); return true; case FragmentMenuItems.ADD_TO_FAVORITES: FavoritesStore.getInstance(getActivity()).addSongId(mSelectedId, mSongName, mAlbumName, mArtistName); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(new long[] { mSelectedId }).show(getFragmentManager(), "CreatePlaylist"); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final long mPlaylistId = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(getActivity(), new long[] { mSelectedId }, mPlaylistId); return true; case FragmentMenuItems.MORE_BY_ARTIST: NavUtils.openArtistProfile(getActivity(), mArtistName); return true; case FragmentMenuItems.USE_AS_RINGTONE: MusicUtils.setRingtone(getActivity(), mSelectedId); return true; case FragmentMenuItems.DELETE: DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null) .show(getFragmentManager(), "DeleteDialog"); return true; default: break; } } return super.onContextItemSelected(item); }
From source file:org.addhen.smssync.presentation.view.ui.activity.MainActivity.java
private void onNavigationItemSelected(final MenuItem menuItem) { final int groupId = menuItem.getGroupId(); mNavigationView.getMenu().setGroupCheckable(R.id.group_messages, (groupId == R.id.group_messages), true); menuItem.setChecked(true);//w w w. jav a 2 s.co m }
From source file:com.ninetwozero.battlelog.fragments.PlatoonMemberFragment.java
public boolean handleSelectedContextItem(AdapterView.AdapterContextMenuInfo info, MenuItem item) { try {/*from w ww .ja v a2s . c o m*/ // Divide & conquer if (item.getGroupId() == 2) { // Get the data PlatoonMemberData data = (PlatoonMemberData) info.targetView.getTag(); // ... if (item.getItemId() == 0) { startActivity( new Intent(context, ProfileActivity.class).putExtra( "profile", data ) ); } else if (item.getItemId() == 1) { if (!data.isAdmin()) { Toast.makeText(context, R.string.info_platoon_member_promoting, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, R.string.info_platoon_member_demoting, Toast.LENGTH_SHORT).show(); } new AsyncPlatoonMemberManagement(context, data.getId(), platoonData.getId(), 1) .execute(!data.isAdmin()); } else if (item.getItemId() == 2) { Toast.makeText(context, R.string.info_platoon_member_kicking, Toast.LENGTH_SHORT).show(); new AsyncPlatoonMemberManagement(context, data.getId(), platoonData.getId(), 2).execute(); } else if (item.getItemId() == 3) { Toast.makeText(context, R.string.info_platoon_member_new_ok, Toast.LENGTH_SHORT).show(); new AsyncPlatoonRespond( context, platoonData.getId(), data.getId(), true ).execute(sharedPreferences.getString(Constants.SP_BL_PROFILE_CHECKSUM, "")); } else if (item.getItemId() == 4) { Toast.makeText(context, R.string.info_platoon_member_new_false, Toast.LENGTH_SHORT).show(); new AsyncPlatoonRespond( context, platoonData.getId(), data.getId(), false ).execute(sharedPreferences.getString(Constants.SP_BL_PROFILE_CHECKSUM, "")); } } } catch (Exception ex) { ex.printStackTrace(); return false; } return true; }
From source file:com.yacorso.nowaste.views.activities.DrawerActivity.java
private void loadNavItems() { int index = 0; Menu navigationMenu = navigationView.getMenu(); navigationMenu.clear();/*from ww w . j ava 2s . c o m*/ navigationItems.clear(); SubMenu fridgeSection = navigationMenu.addSubMenu(getText(R.string.menu_section_fridges)); List<Fridge> fridges = currentUser.getFridges(); for (Fridge fridge : fridges) { navigationItems.put(index, fridge); fridgeSection.add(0, index++, 0, fridge.getName()).setIcon(R.drawable.ic_fridge); } SubMenu customListSection = navigationMenu.addSubMenu(getText(R.string.menu_section_custom_lists)); List<CustomList> customLists = currentUser.getCustomLists(); for (CustomList customList : customLists) { navigationItems.put(index, customList); customListSection.add(1, index++, 0, customList.getName()).setIcon(R.drawable.ic_folder); } navigationMenu.add(2, index++, 0, R.string.menu_add_foodlist).setIcon(R.drawable.ic_add_circle_white); navigationMenu.add(3, index, 0, R.string.menu_title_settings).setIcon(R.drawable.ic_setting_dark); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { if (menuItem.getGroupId() < 2) { changeFragment(menuItem.getItemId(), true); } else if (menuItem.getGroupId() == 2) { launchDialog(ChooseTypeFoodListDialog.newInstance()); } else if (menuItem.getGroupId() == 3) { changeFragment(menuItem.getItemId(), false); } return true; } }); mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerToggle.syncState(); } }); }
From source file:com.meetingninja.csse.meetings.MeetingsFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { int position = item.getItemId(); boolean handled = false; AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (item.getGroupId() == MainActivity.DrawerLabel.MEETINGS.getPosition()) { switch (item.getOrder()) { case 1: // Edit Toast.makeText(getActivity(), item.getTitle(), Toast.LENGTH_SHORT).show(); handled = true;/*from w w w. j av a2 s . c o m*/ break; case 2: // Delete Meeting meeting = meetingAdpt.getItem(position); // mySQLiteAdapter.deleteMeeting(meeting); Need to implement MeetingVolleyAdapter.deleteMeeting(meeting.getID()); meetings.remove(position); meetingAdpt.notifyDataSetChanged(); handled = true; break; default: Log.wtf(TAG, "Invalid context menu option selected"); break; } } else { Log.wtf(TAG, "What happened here?"); } return handled; }
From source file:ru.mtuci.musicanalyzer.apollo.ui.fragments.RecentFragment.java
/** * {@inheritDoc}/*w w w . ja v a 2s .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.REMOVE_FROM_RECENT: mShouldRefresh = true; RecentStore.getInstance(getActivity()).removeItem(mAlbum.mAlbumId); MusicUtils.refresh(); 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.RecentFragment.java
/** * {@inheritDoc}/* w w w.j av a 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(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.REMOVE_FROM_RECENT: mShouldRefresh = true; RecentStore.getInstance(getSherlockActivity()).removeItem(mAlbum.mAlbumId); MusicUtils.refresh(); 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.RecentFragment.java
/** * {@inheritDoc}//from www. j av a 2s . 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.REMOVE_FROM_RECENT: mShouldRefresh = true; RecentStore.getInstance(getActivity()).removeItem(mAlbum.mAlbumId); MusicUtils.refresh(); 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.boko.vimusic.ui.fragments.RecentFragment.java
/** * {@inheritDoc}/*from w w w . j a v a2s . 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.REMOVE_FROM_RECENT: mShouldRefresh = true; RecentStore.getInstance(getActivity()).removeAlbum(mAlbum.getId(), HostType.LOCAL); MusicUtils.refresh(getActivity()); 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); }