List of usage examples for android.view MenuItem getMenuInfo
public ContextMenuInfo getMenuInfo();
From source file:de.hshannover.f4.trust.ironcontrol.view.list_activities.ListOverviewActivity.java
@Override protected void onContextItemSelected(MenuItem item, ListHierarchyType type) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); String listItemId = Long.toString(info.id); switch (item.getItemId()) { case REMOVE_ID: remove(listItemId, type);/*w w w . j a v a 2 s.c o m*/ break; case EDIT_ID: startEditActivity(listItemId); break; case SEARCH_ID: search(listItemId); break; case R.id.bSubscribeUpdate: subscribeUpdate(listItemId); break; case R.id.bSubscribeDelete: subscribeDelete(listItemId); break; } }
From source file:com.flowzr.activity.AbstractListFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { super.onContextItemSelected(item); AdapterView.AdapterContextMenuInfo mi = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.context_entity_info: { viewItem(mi.targetView, mi.position, mi.id); return true; }/*w ww. jav a2 s . co m*/ case R.id.context_entity_edit: { editItem(mi.targetView, mi.position, mi.id); return true; } case R.id.context_entity_delete: { deleteItem(mi.targetView, mi.position, mi.id); return true; } } return false; }
From source file:com.androsz.electricsleepbeta.alarmclock.AlarmClock.java
@Override public boolean onContextItemSelected(final MenuItem item) { final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); final int id = (int) info.id; switch (item.getItemId()) { case R.id.delete_alarm: // Confirm that the alarm will be deleted. new AlertDialog.Builder(this).setTitle(getString(R.string.delete_alarm)) .setMessage(getString(R.string.delete_alarm_confirm)) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override//from w w w . j a v a 2s .c o m public void onClick(final DialogInterface d, final int w) { Alarms.deleteAlarm(AlarmClock.this, id); } }).setNegativeButton(android.R.string.cancel, null).show(); return true; case R.id.enable_alarm: final Cursor c = (Cursor) mAlarmsList.getAdapter().getItem(info.position); final Alarm alarm = new Alarm(c); Alarms.enableAlarm(this, alarm.id, !alarm.enabled); if (!alarm.enabled) { SetAlarm.popAlarmSetToast(this, alarm.hour, alarm.minutes, alarm.daysOfWeek); } return true; case R.id.edit_alarm: final Intent intent = new Intent(this, SetAlarm.class); intent.putExtra(Alarms.ALARM_ID, id); startActivity(intent); return true; default: break; } return super.onContextItemSelected(item); }
From source file:com.money.manager.ex.account.AccountListFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { ContextMenu.ContextMenuInfo menuInfo = item.getMenuInfo(); // ExpandableListView$ExpandableListContextMenuInfo if (!(menuInfo instanceof AdapterView.AdapterContextMenuInfo)) return false; AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; int accountId = (int) info.id; int itemId = item.getItemId(); ContextMenuIds menuId = ContextMenuIds.get(itemId); if (menuId == null) return false; switch (menuId) { case EDIT://from w ww .j a v a2 s. co m startAccountListEditActivity(accountId); break; case DELETE: AccountService service = new AccountService(getActivity()); if (service.isAccountUsed(accountId)) { new MaterialDialog.Builder(getContext()).title(R.string.attention) .icon(new UIHelper(getActivity()).getIcon(GoogleMaterial.Icon.gmd_warning)) .content(R.string.account_can_not_deleted).positiveText(android.R.string.ok) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }).build().show(); } else { showDeleteConfirmationDialog(accountId); } break; } return false; }
From source file:com.deliciousdroid.fragment.BrowseBookmarksFragment.java
@Override public boolean onContextItemSelected(MenuItem aItem) { AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) aItem.getMenuInfo(); final Cursor c = (Cursor) lv.getItemAtPosition(menuInfo.position); Bookmark b = BookmarkManager.CursorToBookmark(c); switch (aItem.getItemId()) { case R.id.menu_bookmark_context_open: openBookmarkInBrowser(b);// w w w .ja v a 2 s . c o m return true; case R.id.menu_bookmark_context_view: viewBookmark(b); return true; case R.id.menu_bookmark_context_edit: bookmarkSelectedListener.onBookmarkEdit(b); return true; case R.id.menu_bookmark_context_delete: bookmarkSelectedListener.onBookmarkDelete(b); return true; case R.id.menu_bookmark_context_share: Log.d("share", "browse"); bookmarkSelectedListener.onBookmarkShare(b); return true; case R.id.menu_bookmark_context_read: readBookmark(b); return true; } return false; }
From source file:in.sundar.unitconverter.FormulaeListActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { // edit formula context menu case EDIT_ID: { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); startFormulaEditActivity(info.id, info.position); return true; }/*from w w w . j a v a 2 s .c o m*/ // delete formula context menu case DELETE_ID: AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); confirmAndDeleteFormula(info.id); return true; } return super.onContextItemSelected(item); }
From source file:org.sufficientlysecure.keychain.ui.KeyListPublicFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { ExpandableListContextMenuInfo expInfo = (ExpandableListContextMenuInfo) item.getMenuInfo(); // expInfo.id would also return row id of childs, but we always want to get the row id of // the group item, thus we are using the following way int groupPosition = ExpandableListView.getPackedPositionGroup(expInfo.packedPosition); long keyRingRowId = getExpandableListAdapter().getGroupId(groupPosition); switch (item.getItemId()) { case Id.menu.update: long updateKeyId = 0; PGPPublicKeyRing updateKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId(mKeyListActivity, keyRingRowId);//w w w. j a v a 2 s.c o m if (updateKeyRing != null) { updateKeyId = PgpHelper.getMasterKey(updateKeyRing).getKeyID(); } if (updateKeyId == 0) { // this shouldn't happen return true; } Intent queryIntent = new Intent(mKeyListActivity, KeyServerQueryActivity.class); queryIntent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID_AND_RETURN); queryIntent.putExtra(KeyServerQueryActivity.EXTRA_KEY_ID, updateKeyId); // TODO: lookup?? startActivityForResult(queryIntent, Id.request.look_up_key_id); return true; case Id.menu.exportToServer: Intent uploadIntent = new Intent(mKeyListActivity, KeyServerUploadActivity.class); uploadIntent.setAction(KeyServerUploadActivity.ACTION_EXPORT_KEY_TO_SERVER); uploadIntent.putExtra(KeyServerUploadActivity.EXTRA_KEYRING_ROW_ID, keyRingRowId); startActivityForResult(uploadIntent, Id.request.export_to_server); return true; case Id.menu.signKey: long keyId = 0; PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId(mKeyListActivity, keyRingRowId); if (signKeyRing != null) { keyId = PgpHelper.getMasterKey(signKeyRing).getKeyID(); } if (keyId == 0) { // this shouldn't happen return true; } Intent signIntent = new Intent(mKeyListActivity, SignKeyActivity.class); signIntent.putExtra(SignKeyActivity.EXTRA_KEY_ID, keyId); startActivity(signIntent); return true; case Id.menu.share_qr_code: // get master key id using row id long masterKeyId = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId); Intent qrCodeIntent = new Intent(mKeyListActivity, ShareActivity.class); qrCodeIntent.setAction(ShareActivity.ACTION_SHARE_KEYRING_WITH_QR_CODE); qrCodeIntent.putExtra(ShareActivity.EXTRA_MASTER_KEY_ID, masterKeyId); startActivityForResult(qrCodeIntent, 0); return true; case Id.menu.share_nfc: // get master key id using row id long masterKeyId2 = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId); Intent nfcIntent = new Intent(mKeyListActivity, ShareNfcBeamActivity.class); nfcIntent.setAction(ShareNfcBeamActivity.ACTION_SHARE_KEYRING_WITH_NFC); nfcIntent.putExtra(ShareNfcBeamActivity.EXTRA_MASTER_KEY_ID, masterKeyId2); startActivityForResult(nfcIntent, 0); return true; case Id.menu.share: // get master key id using row id long masterKeyId3 = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId); Intent shareIntent = new Intent(mKeyListActivity, ShareActivity.class); shareIntent.setAction(ShareActivity.ACTION_SHARE_KEYRING); shareIntent.putExtra(ShareActivity.EXTRA_MASTER_KEY_ID, masterKeyId3); startActivityForResult(shareIntent, 0); return true; default: return super.onContextItemSelected(item); } }
From source file:org.videolan.vlc.gui.DirectoryViewFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { if (!getUserVisibleHint()) return super.onContextItemSelected(item); AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); if (info == null) // info can be null return super.onContextItemSelected(item); int id = item.getItemId(); String mediaLocation = mDirectoryAdapter.getMediaLocation(info.position); if (mediaLocation == null) return super.onContextItemSelected(item); if (id == R.id.directory_view_play) { openMediaFile(info.position);// w ww. jav a 2s .c o m return true; } else if (id == R.id.directory_view_append) { AudioServiceController.getInstance().append(mediaLocation); return true; } else if (id == R.id.directory_view_delete) { AlertDialog alertDialog = CommonDialogs.deleteMedia(getActivity(), mediaLocation, new VLCRunnable() { @Override public void run(Object o) { refresh(); } }); alertDialog.show(); } else if (id == R.id.directory_view_play_audio) { AudioServiceController.getInstance().load(mediaLocation, true); } else if (id == R.id.directory_view_play_video) { VideoPlayerActivity.start(getActivity(), mediaLocation); } return super.onContextItemSelected(item); }
From source file:nya.miku.wishmaster.ui.settings.AutohideActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { if (item.getItemId() == R.id.context_menu_delete) { if (item.getMenuInfo() != null && item.getMenuInfo() instanceof AdapterView.AdapterContextMenuInfo) { int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position; if (position > 0) { rulesJson.remove(position - 1); rulesChanged();/*from w w w. j a v a 2 s . co m*/ } } } return super.onContextItemSelected(item); }
From source file:app.view.chat.ChatHistoryFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { if (item.getItemId() == R.id.delete_message) { EMContact tobeDeleteUser = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position); boolean isGroup = false; if (tobeDeleteUser instanceof EMGroup) isGroup = true;//w w w. j av a2s . co m // ? EMChatManager.getInstance().deleteConversation(tobeDeleteUser.getUsername(), isGroup); InviteMessageDao inviteMessageDao = new InviteMessageDao(getActivity()); inviteMessageDao.deleteMessage(tobeDeleteUser.getUsername()); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); // ? ((MainActivity) getActivity()).updateUnreadLabel(); return true; } return super.onContextItemSelected(item); }