List of usage examples for android.view MenuItem getGroupId
public int getGroupId();
From source file:com.todoroo.astrid.core.CustomFilterActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { if (item.getGroupId() == MENU_GROUP_FILTER) { // give an initial value for the row before adding it CustomFilterCriterion criterion = getNth(item.getItemId(), criteria); final CriterionInstance instance = new CriterionInstance(); instance.criterion = criterion;//from ww w . j a v a 2 s . co m adapter.showOptionsFor(instance, new Runnable() { public void run() { adapter.add(instance); updateList(); } }); return true; } // item type context item else if (item.getGroupId() == MENU_GROUP_CONTEXT_TYPE) { CriterionInstance instance = adapter.getItem(item.getOrder()); instance.type = item.getItemId(); updateList(); } // delete context item else if (item.getGroupId() == MENU_GROUP_CONTEXT_DELETE) { CriterionInstance instance = adapter.getItem(item.getOrder()); adapter.remove(instance); updateList(); } return super.onContextItemSelected(item); }
From source file:com.jefftharris.passwdsafe.PasswdSafeListFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { int group = itsIsContents ? PasswdSafe.CONTEXT_GROUP_LIST_CONTENTS : PasswdSafe.CONTEXT_GROUP_LIST; if (item.getGroupId() != group) { return super.onContextItemSelected(item); }/*from w ww .j a v a2s. c o m*/ switch (item.getItemId()) { case R.id.menu_copy_password: case R.id.menu_copy_user: { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); final PasswdRecordListData listItem = itsAdapter.getItem(info.position); if (listItem.itsIsRecord) { itsSelectedRecord = listItem.itsUuid; itsListener.copyField( (item.getItemId() == R.id.menu_copy_password) ? CopyField.PASSWORD : CopyField.USER_NAME, listItem.itsUuid); } return true; } } return super.onContextItemSelected(item); }
From source file:com.ovrhere.android.currencyconverter.ui.fragments.MainFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { if (item.getGroupId() == Menu.CATEGORY_SECONDARY) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case 0://from w ww . j ava 2 s . c o m int pos1 = info.position; copyConvertedValue(pos1, false); break; case 1: int pos2 = info.position; copyConvertedValue(pos2, true); break; } } return super.onContextItemSelected(item); }
From source file:com.meetingninja.csse.notes.NotesFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { int position = item.getItemId(); boolean handled = false; AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (item.getGroupId() == MainActivity.DrawerLabel.NOTES.getPosition()) { switch (item.getOrder()) { case 1: // Add Content Toast.makeText(getActivity(), String.format("%s", item.getTitle()), Toast.LENGTH_SHORT).show(); handled = true;//w ww . j a v a2 s .c om break; case 2: // Delete delete(noteAdpt.getItem(position)); handled = true; break; case 3: Intent versionControl = new Intent(getActivity(), VersionControlActivity.class); startActivity(versionControl); handled = true; break; case 4: Note n = noteAdpt.getItem(position); if (mergeNote == null) { Log.d("MERGE", "merge_a: " + n.getID()); mergeNote = n; Toast.makeText(getActivity(), String.format("Select second note to merge."), Toast.LENGTH_LONG) .show(); } else if (mergeNote.getID().equalsIgnoreCase(n.getID())) { Log.d("MERGE", "merge_b: " + n.getID() + " : " + mergeNote.getID()); mergeNote = null; Toast.makeText(getActivity(), String.format("Error: Same note selected twice. Please reselect notes to merge."), Toast.LENGTH_LONG).show(); } else { Log.d("MERGE", "merge_c: " + n.getID() + " : " + mergeNote.getID()); Toast.makeText(getActivity(), String.format("Merging " + n.getTitle() + " into " + mergeNote.getTitle()), Toast.LENGTH_LONG).show(); mergeNote.setContent(mergeNote.getContent() + "\n" + n.getContent()); delete(n); updateNote(mergeNote); mergeNote = null; populateList(); } break; default: Log.wtf(TAG, "Invalid context menu option selected"); break; } } else { Log.wtf(TAG, "What happened here?"); } return handled; }
From source file:com.cyanogenmod.effem.FmRadio.java
/** * React to a selection in the option menu *//* ww w.j av a2 s . co m*/ @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getGroupId()) { case BAND_SELECTION_MENU: switch (item.getItemId()) { case BAND_US: mSelectedBand = FmBand.BAND_US; item.setChecked(true); break; case BAND_EU: mSelectedBand = FmBand.BAND_EU; item.setChecked(true); break; case BAND_JAPAN: mSelectedBand = FmBand.BAND_JAPAN; item.setChecked(true); break; case BAND_CHINA: mSelectedBand = FmBand.BAND_CHINA; item.setChecked(true); break; default: break; } mWorkerHandler.post(new Runnable() { public void run() { mService.stopRadio(); mService.startRadio(mSelectedBand, 0, mSelectedOutput); } }); break; case LOUDSPEAKER_SELECTION_MENU: mSelectedOutput = (item.getItemId() == OUTPUT_HEADSET) ? 0 : 1; mWorkerHandler.post(new Runnable() { public void run() { mService.stopRadio(); mService.startRadio(mSelectedBand, mCurrentFrequency, mSelectedOutput); } }); break; case STATION_SELECTION_MENU: final int freq = mMenuAdapter.getItem(getSelectStationMenuItem(item)).frequency; mWorkerHandler.post(new Runnable() { public void run() { if (!mService.isStarted()) mService.startRadio(mSelectedBand, freq, mSelectedOutput); else mService.changeFrequency(FmRadioService.SEEK_ABSOLUTE, freq); } }); break; default: break; } return super.onOptionsItemSelected(item); }
From source file:com.appunite.appunitevideoplayer.PlayerActivity.java
private boolean onTrackItemClick(MenuItem item, int type) { if (player == null || item.getGroupId() != MENU_GROUP_TRACKS) { return false; }/* w ww. ja v a 2s . c o m*/ player.setSelectedTrack(type, item.getItemId() - ID_OFFSET); return true; }
From source file:org.yammp.fragment.ArtistFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { if (item.getGroupId() == hashCode()) { switch (item.getItemId()) { case PLAY_SELECTION: if (mGroupSelected && !mChildSelected) { long[] list = mUtils.getSongListForArtist(mSelectedGroupId); mUtils.playAll(list, 0); } else if (mChildSelected && !mGroupSelected) { long[] list = mUtils.getSongListForAlbum(mSelectedChildId); mUtils.playAll(list, 0); }/*from www.j a v a 2 s . c o m*/ return true; case DELETE_ITEMS: if (mGroupSelected && !mChildSelected) { DeleteDialogFragment.getInstance(false, mSelectedGroupId, DeleteDialogFragment.ARTIST) .show(getFragmentManager(), "dialog"); } else if (mChildSelected && !mGroupSelected) { DeleteDialogFragment.getInstance(false, mSelectedChildId, DeleteDialogFragment.ARTIST) .show(getFragmentManager(), "dialog"); } return true; case DELETE_LYRICS: if (mGroupSelected && !mChildSelected) { DeleteDialogFragment.getInstance(true, mSelectedGroupId, DeleteDialogFragment.ARTIST) .show(getFragmentManager(), "dialog"); } else if (mChildSelected && !mGroupSelected) { DeleteDialogFragment.getInstance(true, mSelectedChildId, DeleteDialogFragment.ARTIST) .show(getFragmentManager(), "dialog"); } return true; case SEARCH: if (mGroupSelected && !mChildSelected) { doSearch(mCurrentGroupArtistName, null); } else if (mChildSelected && !mGroupSelected) { doSearch(mCurrentChildArtistNameForAlbum, mCurrentChildAlbumName); } return true; } } return super.onContextItemSelected(item); }
From source file:com.github.kanata3249.ffxieq.android.EquipmentSelectorActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { EquipmentListView elv = (EquipmentListView) findViewById(R.id.ListView); if (item.getGroupId() == R.id.FilterByType) { if (item.getItemId() < 0) { mFilterByType = ""; } else {//from w w w . j ava 2s . c o m mFilterByType = (String) item.getTitle(); } elv.setFilterByType(mFilterByType); return true; } switch (item.getItemId()) { case R.id.OrderByName: mOrderByName = !mOrderByName; if (elv != null) { elv.setOrderByName(mOrderByName); } return true; case R.id.Remove: { Intent result = new Intent(); result.putExtra("From", "EquipmentSelector"); result.putExtra("Part", mPart); result.putExtra("Id", -1); result.putExtra("AugId", -1); setResult(RESULT_OK, result); finish(); return true; } case R.id.Filter: showDialog(0); return true; case R.id.ResetFilter: if (elv != null) { elv.setFilter(""); } mFilterID = -1; return true; case R.id.AugmentList: { Intent result = new Intent(); result.putExtra("From", "EquipmentSelector"); result.putExtra("Part", mPart); setResult(RESULT_FIRST_USER, result); finish(); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:com.github.kanata3249.ffxieq.android.AugmentSelectorActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { AugmentListView lv = (AugmentListView) findViewById(R.id.ListView); if (item.getGroupId() == R.id.FilterByType) { if (item.getItemId() < 0) { mFilterByType = ""; } else {/*from w w w .ja va 2s. c o m*/ mFilterByType = (String) item.getTitle(); } lv.setFilterByType(mFilterByType); return true; } switch (item.getItemId()) { case R.id.OrderByName: mOrderByName = !mOrderByName; if (lv != null) { lv.setOrderByName(mOrderByName); } return true; case R.id.Remove: { Intent result = new Intent(); result.putExtra("From", "AugmentSelector"); result.putExtra("Part", mPart); result.putExtra("Id", -1); result.putExtra("AugId", -1); setResult(RESULT_OK, result); finish(); return true; } case R.id.Filter: showDialog(0); return true; case R.id.ResetFilter: if (lv != null) { lv.setFilter(""); } mFilterID = -1; return true; case R.id.EquipmentList: { Intent result = new Intent(); result.putExtra("From", "AugmentSelector"); result.putExtra("Part", mPart); setResult(RESULT_FIRST_USER, result); finish(); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:io.mapsquare.osmcontributor.ui.activities.MapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); ((OsmTemplateApplication) getApplication()).getOsmTemplateComponent().inject(this); ButterKnife.bind(this); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); setSupportActionBar(toolbar);//from w ww .j av a2 s . com eventBus.post(new UpdateFirstConnectionEvent()); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { switch (menuItem.getGroupId()) { case R.id.drawer_options_group: onOptionsClick(menuItem); break; case R.id.sync: onOptionsSyncClick(menuItem); break; } return true; } }); filterView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { if (menuItem.getItemId() == R.id.select_all_item) { selectAllMenuItem.setChecked(!selectAllMenuItem.isChecked()); onSelectAllClick(); } else if (menuItem.getItemId() != R.id.display_open_notes_item && menuItem.getItemId() != R.id.display_closed_notes_item) { menuItem.setChecked(!menuItem.isChecked()); onFilterItemClick(menuItem); } else { menuItem.setChecked(!menuItem.isChecked()); onNoteItemClick(menuItem); } return true; } }); selectAllMenuItem = filterView.getMenu().findItem(R.id.select_all_item); if (!FlavorUtils.isPoiStorage() && configManager.hasPoiModification()) { navigationView.getMenu().findItem(R.id.edit_way).setVisible(true); } if (configManager.hasPoiAddition()) { navigationView.getMenu().findItem(R.id.replay_tuto_menu).setVisible(true); } navigationView.getMenu().findItem(R.id.save_changes).setEnabled(false); drawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() { @Override public void onDrawerSlide(View drawerView, float slideOffset) { } @Override public void onDrawerOpened(View drawerView) { eventBus.post(new PleaseTellIfDbChanges()); } @Override public void onDrawerClosed(View drawerView) { } @Override public void onDrawerStateChanged(int newState) { } }); navigationView.getMenu().findItem(R.id.manage_poi_types) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { startPoiTypeEditionActivity(); return true; } }); // Get the arpi fragment. arpiGlFragment = (ArpiGlFragment) getFragmentManager().findFragmentById(R.id.engine_fragment); getFragmentManager().beginTransaction().hide(arpiGlFragment).commit(); if (sharedPreferences.getBoolean(getString(R.string.easter_egg), false)) { navigationView.getMenu().findItem(R.id.arpi_view).setVisible(true); } }