List of usage examples for android.view MenuItem getMenuInfo
public ContextMenuInfo getMenuInfo();
From source file:com.app.khclub.base.easeim.activity.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;//from ww w.ja va2 s. c o m // ? EMChatManager.getInstance().deleteConversation(tobeDeleteUser.getUsername(), isGroup); InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity()); inviteMessgeDao.deleteMessage(tobeDeleteUser.getUsername()); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); // ? ((MainTabActivity) getActivity()).updateUnreadLabel(); return true; } return super.onContextItemSelected(item); }
From source file:org.gateshipone.odyssey.fragments.PlaylistTracksFragment.java
/** * Hook called when an menu item in the context menu is selected. * * @param item The menu item that was selected. * @return True if the hook was consumed here. *///from w w w.java2 s .c om @Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); if (info == null) { return super.onContextItemSelected(item); } switch (item.getItemId()) { case R.id.fragment_playlist_tracks_action_enqueue: enqueueTrack(info.position); return true; case R.id.fragment_playlist_tracks_action_enqueueasnext: enqueueTrackAsNext(info.position); return true; case R.id.fragment_playlist_tracks_action_remove: removeTrackFromPlaylist(info.position); return true; default: return super.onContextItemSelected(item); } }
From source file:com.samebits.beacon.locator.ui.fragment.TrackedBeaconsFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { ContextMenuRecyclerView.RecyclerContextMenuInfo info = (ContextMenuRecyclerView.RecyclerContextMenuInfo) item .getMenuInfo();//from ww w .j ava 2s. co m switch (item.getItemId()) { case R.id.action_add: newBeaconAction(mBeaconsAdapter.getBeacon(info.position).getId()); return true; case R.id.action_delete: removeBeacon(mBeaconsAdapter.getBeacon(info.position).getId()); return true; default: return super.onOptionsItemSelected(item); } }
From source file:ca.cs.ualberta.localpost.view.GreatestTabView.java
@Override public boolean onContextItemSelected(MenuItem item) { ConnectivityCheck conn = new ConnectivityCheck(getActivity()); // Get item list index ElasticSearchOperations es = new ElasticSearchOperations(); AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); int index = (int) info.id; switch (item.getItemId()) { case Menu.FIRST:// UpRad if (conn.isConnectingToInternet()) { Toast.makeText(getActivity(), "UpRad", Toast.LENGTH_SHORT).show(); model.get(index).incRadish(); es.execute(1, model.get(index).getPostId(), model.get(index), null); return true; } else {// w w w . ja va 2s. co m Toast.makeText(getActivity(), "You require connectivity to Uprad", Toast.LENGTH_SHORT).show(); return true; } case Menu.FIRST + 1: // DownRad if (conn.isConnectingToInternet()) { Toast.makeText(getActivity(), "DownRad", Toast.LENGTH_SHORT).show(); model.get(index).decRadish(); es.execute(1, model.get(index).getPostId(), model.get(index), null); return true; } else { Toast.makeText(getActivity(), "You require connectivity to Downrad", Toast.LENGTH_SHORT).show(); return true; } case Menu.FIRST + 2: // Favorites Serialize.SaveComment(model.get(index), getActivity(), "favourite"); Toast.makeText(getActivity(), "Comment has been Favorited", Toast.LENGTH_SHORT).show(); Serialize.update(model.get(index), getActivity(), "favoritecomment.json"); return true; } return super.onContextItemSelected(item); }
From source file:cn.hbm.superwechat.activity.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 . ja v a 2s . c o m*/ // ? EMChatManager.getInstance().deleteConversation(tobeDeleteUser.getUsername(), isGroup); InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity()); inviteMessgeDao.deleteMessage(tobeDeleteUser.getUsername()); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); // ? ((MainActivity) getActivity()).updateUnreadLabel(); return true; } return super.onContextItemSelected(item); }
From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedMembersFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); int menuItemIndex = item.getItemId(); Cursor cursor = (Cursor) mContacts.getItem(info.position); final Contact c = Helpers.getContact(getActivity(), cursor.getLong(cursor.getColumnIndexOrThrow(Contact._ID))); switch (menuItemIndex) { case 0:/*from w ww . ja va 2 s .c om*/ Helpers.deleteContact(getActivity(), c.id); break; } return true; }
From source file:ca.cs.ualberta.localpost.view.PicTabView.java
@Override public boolean onContextItemSelected(MenuItem item) { ConnectivityCheck conn = new ConnectivityCheck(getActivity()); // Get item list index ElasticSearchOperations es = new ElasticSearchOperations(); AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); int index = (int) info.id; switch (item.getItemId()) { case Menu.FIRST: if (conn.isConnectingToInternet()) { Toast.makeText(getActivity(), "UpRad", Toast.LENGTH_SHORT).show(); model.get(index).incRadish(); es.execute(1, model.get(index).getPostId(), model.get(index), null); return true; } else {//from w ww. j a v a 2s . c o m Toast.makeText(getActivity(), "You require connectivity to Uprad", Toast.LENGTH_SHORT).show(); return true; } case Menu.FIRST + 1: if (conn.isConnectingToInternet()) { Toast.makeText(getActivity(), "DownRad", Toast.LENGTH_SHORT).show(); model.get(index).decRadish(); es.execute(1, model.get(index).getPostId(), model.get(index), null); return true; } else { Toast.makeText(getActivity(), "You require connectivity to Downrad", Toast.LENGTH_SHORT).show(); return true; } case Menu.FIRST + 2: Serialize.SaveComment(model.get(index), getActivity(), "favourite"); Toast.makeText(getActivity(), "Comment has been Favorited", Toast.LENGTH_SHORT).show(); Serialize.update(model.get(index), getActivity(), "favoritecomment.json"); return true; } return super.onContextItemSelected(item); }
From source file:com.chaosinmotion.securechat.activities.MainActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); List<SCMessageDatabase.Sender> l = SCMessageQueue.get().getSenders(); SCMessageDatabase.Sender sender = l.get(info.position); if (item.getItemId() == 0) { /*//w ww . j a v a2s . c o m * Delete the sender that was clicked on */ SCMessageQueue.get().deleteSender(sender.getSenderID()); senderAdapter.notifyDataSetChanged(); } return true; }
From source file:nu.firetech.android.pactrack.frontend.ParcelListFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.action_delete: UICommon.deleteParcel(info.id, getActivity(), mDbAdapter, new Runnable() { @Override// w w w.ja va 2s. c o m public void run() { refreshDone(); } }); return true; case R.id.action_edit: ParcelIdDialog.create(getFragmentManager(), info.id); return true; case R.id.action_auto_include: mDbAdapter.setAutoUpdate(info.id, !item.isChecked()); mParent.onAutoUpdateChanged(info.id, !item.isChecked()); return true; case R.id.action_refresh: mParent.showParcel(info.id, true); return true; } return super.onContextItemSelected(item); }
From source file:com.pindroid.fragment.BrowseBookmarkFeedFragment.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 .j a va2 s.c o m return true; case R.id.menu_bookmark_context_view: viewBookmark(b); return true; case R.id.menu_bookmark_context_add: addBookmark(b); return true; case R.id.menu_bookmark_context_read: readBookmark(b); return true; case R.id.menu_bookmark_context_share: bookmarkSelectedListener.onBookmarkShare(b); return true; } return false; }