List of usage examples for android.support.v4.view MenuItem getItemId
public int getItemId();
From source file:com.chess.genesis.activity.GameListOnlineFrag.java
@Override public boolean onContextItemSelected(final MenuItem item) { if (!act.lastContextMenu.equals(getBTag())) return super.onContextItemSelected(item); switch (item.getItemId()) { case R.id.new_game: case R.id.resync: case R.id.readall_msgs: return onOptionsItemSelected(item); }// w ww . j av a 2s.c o m final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); final GameListAdapter listAdapter = gamelistadapter_arr[pager.getCurrentItem()]; final Bundle bundle = (Bundle) listAdapter.getItem((int) info.id); switch (item.getItemId()) { case R.id.delete_game: new DeleteArchiveDialog(act, handle, bundle.getString("gameid")).show(); break; case R.id.local_copy: final int type = (pager.getCurrentItem() == ARCHIVE_PAGE) ? Enums.ARCHIVE_GAME : Enums.ONLINE_GAME; new CopyGameConfirm(act, bundle.getString("gameid"), type).show(); break; case R.id.rematch: final String username = listAdapter.getExtras().getString("username"); final String opponent = username.equals(bundle.getString("white")) ? bundle.getString("black") : bundle.getString("white"); new RematchConfirm(act, handle, opponent).show(); break; case R.id.nudge: new NudgeConfirm(act, handle, bundle.getString("gameid")).show(); break; case R.id.share_game: sendGame(bundle); break; default: return super.onContextItemSelected(item); } return true; }
From source file:mobisocial.musubi.ui.fragments.ContactsFragment.java
public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); int menuItemIndex = item.getItemId(); Cursor cursor = (Cursor) mContacts.getItem(info.position); final MIdentity ident = mIdentityManager .getIdentityForId(cursor.getLong(cursor.getColumnIndexOrThrow(MIdentity.COL_ID))); switch (menuItemIndex) { case 0://w w w .j a v a 2 s . com ignoreContact(ident); break; case 1: String email = ident.principal_; if (email == null) { Toast.makeText(getActivity(), "Oops, couldn't set up email.", Toast.LENGTH_SHORT).show(); return true; } Intent intent = EmailInviteActivity.getInviteIntentForEmail(getActivity(), email); startActivity(intent); break; } return true; }
From source file:org.jitsi.android.gui.chat.ChatActivity.java
/** * Invoked when an options item has been selected. * * @param item the item that has been selected */// w ww . ja v a 2s. com @Override public boolean onOptionsItemSelected(MenuItem item) { String selectedChat = chatPagerAdapter.getChatId(chatPager.getCurrentItem()); ChatSession selectedSession = ChatSessionManager.getActiveChat(selectedChat); // Handle item selection switch (item.getItemId()) { case R.id.call_contact: Contact contact = selectedSession.getMetaContact().getDefaultContact(); AndroidCallUtil.createCall(this, contact.getAddress(), contact.getProtocolProvider()); return true; case R.id.close_chat: ChatSessionManager.removeActiveChat(selectedSession); chatPagerAdapter.removeChatSession(selectedChat); if (chatPagerAdapter.getCount() <= 0) { setCurrentChatId(null); startActivity(JitsiApplication.getHomeIntent()); } else { int pos = chatPager.getCurrentItem(); setCurrentChatId(chatPagerAdapter.getChatId(pos)); displaySelectedChatInfo(); } return true; case R.id.close_all_chats: setCurrentChatId(null); ChatSessionManager.removeAllActiveChats(); chatPagerAdapter.removeAllChatSessions(); startActivity(JitsiApplication.getHomeIntent()); default: return super.onOptionsItemSelected(item); } }
From source file:mobisocial.musubi.ui.fragments.FeedViewFragment.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_feed_details: Intent intent = new Intent(getActivity(), FeedDetailsActivity.class); intent.setDataAndType(mFeedUri, MusubiContentProvider.getType(Provided.FEEDS_ID)); startActivity(intent);//from w w w . j av a2 s . c om return true; } return super.onOptionsItemSelected(item); }
From source file:mobisocial.musubi.ImageGalleryActivity.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_SET_PROFILE: { new Thread() { public void run() { long objId = (Long) mGallery.getSelectedView().getTag(); DbObj obj = mMusubi.objForId(objId); byte[] picBytes = obj.getRaw(); IdentitiesManager idMan = new IdentitiesManager( App.getDatabaseSource(ImageGalleryActivity.this)); idMan.updateMyProfileThumbnail(ImageGalleryActivity.this, picBytes, true); toast("Set profile picture."); };//w w w . j a v a 2 s . c o m }.start(); return true; } case MENU_SHARE: { long objId = (Long) mGallery.getSelectedView().getTag(); DbObj obj = mMusubi.objForId(objId); new SharePhotoAction().actOn(this, new PictureObj(), obj); return true; } case MENU_EDIT: { long objId = (Long) mGallery.getSelectedView().getTag(); DbObj obj = mMusubi.objForId(objId); doActivityForResult(new EditPhotoAction.EditCallout(this, obj)); return true; } default: return false; } }
From source file:com.ushahidi.android.app.ui.phone.AddCheckinActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { showDialog();// ww w . j a v a2 s . co m return true; } else if (item.getItemId() == R.id.menu_send_checkin) { validateCheckins(); return true; } else if (item.getItemId() == R.id.menu_cancel_checkin) { showDialog(DIALOG_SHOW_PROMPT); return true; } return super.onOptionsItemSelected(item); }
From source file:com.abcvoipsip.ui.messages.ConversationsListFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); if (info.position > 0) { ConversationListItemViews cri = (ConversationListItemViews) info.targetView.getTag(); if (cri != null) { switch (item.getItemId()) { case MENU_DELETE: { confirmDeleteThread(cri.getRemoteNumber()); break; }/*from w ww .j av a 2 s . c o m*/ case MENU_VIEW: { viewDetails(info.position, cri); break; } default: break; } } } return super.onContextItemSelected(item); }
From source file:com.ushahidi.android.app.ui.tablet.ListReportFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.menu_refresh) { refresh = item;// w w w . j a va 2 s . c om new RefreshReports(getActivity()).execute((String) null); return true; } else if (item.getItemId() == R.id.menu_add) { launchAddReport(0); return true; } else if (item.getItemId() == R.id.filter_by) { showDropDownNav(); return true; } else if (item.getItemId() == android.R.id.home) { getActivity().finish(); return true; } return super.onOptionsItemSelected(item); }
From source file:com.ushahidi.android.app.ui.phone.AddCheckinActivity.java
public boolean performAction(android.view.MenuItem item, int position) { if (item.getItemId() == R.id.remove_photo) { // adding a new report if (id == 0) { // Delete by name if (ImageManager.deletePendingPhoto(this, "/" + pendingPhoto.getItem(position).getPhoto())) { pendingPhoto.refresh();/*w ww . j a v a 2 s. c o m*/ } return true; } else { // editing existing report if (ImageManager.deletePendingPhoto(this, "/" + pendingPhoto.getItem(position).getPhoto())) { pendingPhoto.removeItem(position); } return true; } } return false; }
From source file:foam.littlej.android.app.ui.phone.AddCheckinActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { showDialog();// w w w .jav a2 s. c o m return true; } else if (item.getItemId() == R.id.menu_send_checkin) { validateCheckins(); return true; } else if (item.getItemId() == R.id.menu_cancel_checkin) { showDialog(DIALOG_SHOW_PROMPT); return true; } return super.onOptionsItemSelected(item); }