List of usage examples for android.view MenuItem getMenuInfo
public ContextMenuInfo getMenuInfo();
From source file:com.money.manager.ex.currency.list.CurrencyListFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); // take cursor and move to position Cursor cursor = ((CurrencyListAdapter) getListAdapter()).getCursor(); cursor.moveToPosition(info.position); int currencyId = cursor.getInt(cursor.getColumnIndex(Currency.CURRENCYID)); CurrencyUIFeatures ui = new CurrencyUIFeatures(getActivity()); // check item selected int selectedItem = item.getItemId(); switch (selectedItem) { case 0: //EDIT ui.startCurrencyEditActivity(currencyId); break;/*from w w w .ja v a 2s .c om*/ case 1: // Chart // remember the device orientation and return to it after the chart. this.mPreviousOrientation = ActivityUtils.forceCurrentOrientation(getActivity()); // add the currency information. String symbol = cursor.getString(cursor.getColumnIndex(Currency.CURRENCY_SYMBOL)); CurrencyService currencyService = this.getService(); String baseCurrencyCode = currencyService.getBaseCurrencyCode(); Intent intent = new Intent(getActivity(), CurrencyChartActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.putExtra(Currency.CURRENCY_SYMBOL, symbol); intent.putExtra(CurrencyChartActivity.BASE_CURRENCY_SYMBOL, baseCurrencyCode); startActivity(intent); break; case 2: // Update exchange rate getService().updateExchangeRate(currencyId); break; case 3: //DELETE CurrencyService service = new CurrencyService(getActivity()); boolean used = service.isCurrencyUsed(currencyId); if (used) { ui.notifyCurrencyCanNotBeDeleted(); } else { ContentValues contentValues = new ContentValues(); contentValues.put(Account.CURRENCYID, currencyId); ui.showDialogDeleteCurrency(currencyId, info.position); } break; } return false; }
From source file:com.radicaldynamic.groupinform.activities.AccountFolderList.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); AccountFolder folder = (AccountFolder) getListView().getItemAtPosition(info.position); switch (item.getItemId()) { case CONTEXT_MENU_EDIT: if (Collect.getInstance().getInformOnlineState().getDeviceId().equals(folder.getOwnerId())) { Intent i = new Intent(this, AccountFolderActivity.class); i.putExtra(AccountFolderActivity.KEY_FOLDER_ID, folder.getId()); i.putExtra(AccountFolderActivity.KEY_FOLDER_REV, folder.getRev()); i.putExtra(AccountFolderActivity.KEY_FOLDER_OWNER, folder.getOwnerId()); i.putExtra(AccountFolderActivity.KEY_FOLDER_NAME, folder.getName()); i.putExtra(AccountFolderActivity.KEY_FOLDER_DESC, folder.getDescription()); i.putExtra(AccountFolderActivity.KEY_FOLDER_VISIBILITY, folder.getVisibility()); startActivity(i);//w w w . j a va 2 s. co m } else { showDialog(DIALOG_DENIED_NOT_OWNER); } break; case CONTEXT_MENU_INFO: mFolder = folder; showDialog(DIALOG_MORE_INFO); break; default: return super.onContextItemSelected(item); } return true; }
From source file:com.fututel.ui.account.AccountsEditListFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { final SipProfile account = profileFromContextMenuInfo(item.getMenuInfo()); if (account == null) { // For some reason the requested item isn't available, do nothing return super.onContextItemSelected(item); }//from w w w . ja v a 2 s .c o m switch (item.getItemId()) { case MENU_ITEM_DELETE: { getActivity().getContentResolver() .delete(ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, account.id), null, null); return true; } case MENU_ITEM_MODIFY: { showDetails(account.id, account.wizard); return true; } case MENU_ITEM_ACTIVATE: { ContentValues cv = new ContentValues(); cv.put(SipProfile.FIELD_ACTIVE, !account.active); getActivity().getContentResolver() .update(ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, account.id), cv, null, null); return true; } case MENU_ITEM_WIZARD: { Intent it = new Intent(getActivity(), WizardChooser.class); it.putExtra(Intent.EXTRA_UID, account.id); startActivityForResult(it, CHANGE_WIZARD); return true; } } return super.onContextItemSelected(item); }
From source file:com.keepassdroid.fileselect.FileSelectActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { super.onContextItemSelected(item); if (item.getItemId() == CMENU_CLEAR) { AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) item.getMenuInfo(); TextView tv = (TextView) acmi.targetView; String filename = tv.getText().toString(); new AsyncTask<String, Void, Void>() { protected java.lang.Void doInBackground(String... args) { String filename = args[0]; fileHistory.deleteFile(Uri.parse(args[0])); return null; }//from w w w. j a v a2 s. c o m protected void onPostExecute(Void v) { refreshList(); } }.execute(filename); return true; } return false; }
From source file:com.android.browser.BookmarksPageCallbacks.java
@Override public boolean onContextItemSelected(MenuItem item) { if (!(item.getMenuInfo() instanceof BookmarkContextMenuInfo)) { return false; }//from w w w . j a v a2 s .c om BookmarkContextMenuInfo i = (BookmarkContextMenuInfo) item.getMenuInfo(); // If we have no menu info, we can't tell which item was selected. if (i == null) { return false; } if (handleContextItem(item.getItemId(), i.groupPosition, i.childPosition)) { return true; } return super.onContextItemSelected(item); }
From source file:com.baohume.browser.BookmarksPageCallbacks.java
@Override public boolean onContextItemSelected(MenuItem item) { if (!(item.getMenuInfo() instanceof BookmarkExpandableView.BookmarkContextMenuInfo)) { return false; }/*from w ww.j a v a 2 s . c o m*/ BookmarkExpandableView.BookmarkContextMenuInfo i = (BookmarkExpandableView.BookmarkContextMenuInfo) item .getMenuInfo(); // If we have no menu info, we can't tell which item was selected. if (i == null) { return false; } if (handleContextItem(item.getItemId(), i.groupPosition, i.childPosition)) { return true; } return super.onContextItemSelected(item); }
From source file:org.opensmc.mytracks.cyclesmc.MainInput.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case CONTEXT_RETRY: retryTripUpload(info.id);// w w w . java2 s. co m return true; case CONTEXT_DELETE: deleteTrip(info.id); return true; default: return super.onContextItemSelected(item); } }
From source file:com.ninetwozero.battlelog.DashboardActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { // Declare... AdapterView.AdapterContextMenuInfo info; // Let's try to get some menu information via a try/catch try {//from w ww. j ava2s .com info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); } catch (ClassCastException e) { e.printStackTrace(); return false; } if (slidingDrawer.isOpened()) { switch (viewPagerCom.getCurrentItem()) { case 0: fragmentComFriends.handleSelectedContextItem(info, item); break; default: break; } } else { switch (viewPager.getCurrentItem()) { case VIEWPAGER_POSITION_FEED: return fragmentFeed.handleSelectedContextItem(info, item); default: break; } } return true; }
From source file:com.roamprocess1.roaming4world.ui.messages.ConversationsListFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); System.out.println("Converseattion onContextItemSelected"); if (info.position >= 0) { ConversationListItemViews cri = (ConversationListItemViews) info.targetView.getTag(); System.out.println("Converseattion:" + cri); if (cri != null) { switch (item.getItemId()) { case MENU_DELETE: { confirmDeleteThread(cri.getRemoteNumber()); break; }//from w w w. j a v a2 s .c o m case MENU_VIEW: { viewDetails(info.position, cri); break; } default: break; } } } return super.onContextItemSelected(item); }
From source file:com.asksven.commandcenter.BasicMasterFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo(); // check if the called back fragment is the one that has initiated the menu action // based on the group id. if not do noting if (item.getGroupId() == m_iContextMenuId) { try {/*from w w w . j a v a2 s .c o m*/ m_myCommand = m_myItems.get(menuInfo.position); } catch (Exception e) { m_myCommand = null; Log.e(TAG, "An error occured getting the selected command: " + e.getMessage()); } switch (item.getItemId()) { case CONTEXT_ADD_ID: if (m_myCommand != null) { showDetails(-1); } return true; case CONTEXT_DELETE_ID: if (m_myCommand != null) { Log.i(TAG, "Deleting command"); // TODO add yes/no dialog deleteCommand(m_myCommand.getId()); } return true; case CONTEXT_EDIT_ID: if (m_myCommand != null) { Log.i(TAG, "Editing command"); showDetails(m_myCommand.getId()); } return true; case CONTEXT_EXECUTE_ID: if (m_myCommand != null) { Log.i(TAG, "Running command"); executeCommand(m_myCommand); refreshList(); } return true; case CONTEXT_RELOAD: if (m_myCommand != null) { // new RefreshCommandsCacheTask().execute(""); this.refreshCommandsCache(); } return true; case CONTEXT_REFRESH: if (m_myCommand != null) { refreshList(); return true; } case CONTEXT_ADDUSER_ID: if (m_myCommand != null) { Log.i(TAG, "Copying command to user commands"); copyToUser(m_myCommand); refreshList(); return true; } default: return false; } } else { return super.onContextItemSelected(item); } }