List of usage examples for android.view MenuItem getMenuInfo
public ContextMenuInfo getMenuInfo();
From source file:ca.psiphon.ploggy.FragmentFriendList.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); if (item.getItemId() == R.id.action_friend_list_delete_friend) { final Data.Friend finalFriend = (Data.Friend) getListView().getItemAtPosition(info.position); new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.label_delete_friend_title)) .setMessage(//from w ww. j ava2 s . c om getString(R.string.label_delete_friend_message, finalFriend.mPublicIdentity.mNickname)) .setPositiveButton(getString(R.string.label_delete_friend_positive), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Data.getInstance().removeFriend(finalFriend.mId); } catch (Data.DataNotFoundError e) { // Ignore } catch (Utils.ApplicationError e) { Log.addEntry(LOG_TAG, "failed to delete friend: " + finalFriend.mPublicIdentity.mNickname); } } }) .setNegativeButton(getString(R.string.label_delete_friend_negative), null).show(); return true; } return super.onContextItemSelected(item); }
From source file:com.happynetwork.vrestate.activitys.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 . jav a 2 s .co m // ? EMChatManager.getInstance().deleteConversation(tobeDeleteUser.getUsername(), isGroup); InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity()); inviteMessgeDao.deleteMessage(tobeDeleteUser.getUsername()); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); // ? return true; } return super.onContextItemSelected(item); }
From source file:app.view.chat.ContactListFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { if (item.getItemId() == R.id.delete_contact) { User tobeDeleteUser = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position); // ?/*ww w . j a va 2 s . c o m*/ deleteContact(tobeDeleteUser); // ? InviteMessageDao dao = new InviteMessageDao(getActivity()); dao.deleteMessage(tobeDeleteUser.getUsername()); return true; } else if (item.getItemId() == R.id.add_to_blacklist) { User user = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position); moveToBlacklist(user.getUsername()); return true; } return super.onContextItemSelected(item); }
From source file:com.easemob.chatui.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. j a v a 2 s. 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:com.safeness.im.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 w ww . jav a 2s. co m // ? EMChatManager.getInstance().deleteConversation(tobeDeleteUser.getUsername(), isGroup); InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity()); inviteMessgeDao.deleteMessage(tobeDeleteUser.getUsername()); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); // ? puchao //((MainActivity) getActivity()).updateUnreadLabel(); return true; } return super.onContextItemSelected(item); }
From source file:org.protocoder.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); int itemId = item.getItemId(); if (itemId == android.R.id.home) { return true; } else if (itemId == R.id.menu_new) { Protocoder.getInstance(this).protoScripts.createProjectDialog(); return true; } else if (itemId == R.id.menu_help) { Protocoder.getInstance(this).app.showHelp(true); return true; } else if (itemId == R.id.menu_settings) { Protocoder.getInstance(this).app.showSettings(true); return true; } else {/*from w w w .j a va 2 s . co m*/ return super.onOptionsItemSelected(item); } }
From source file:ca.cs.ualberta.localpost.view.LastestTabView.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 ww w . j a v a 2 s. co 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.youti.chat.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 www . jav a2 s . com // ? EMChatManager.getInstance().deleteConversation(tobeDeleteUser.getUsername(), isGroup); InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity()); inviteMessgeDao.deleteMessage(tobeDeleteUser.getUsername()); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); // ? ((MyMessageActivity) getActivity()).updateUnreadLabel(); return true; } return super.onContextItemSelected(item); }
From source file:net.potterpcs.recipebook.DirectionsEditor.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); String selected = adapter.getItem(info.position); String selectedPhoto = photoUris.get(info.position); switch (item.getItemId()) { case R.id.ctxdeletedirection: // "Delete" option adapter.remove(selected);//from ww w.j av a 2 s .c om photoUris.remove(info.position); currentDirection = -1; currentPhoto = null; return true; case R.id.ctxeditdirection: // "Edit" option currentDirection = info.position; currentPhoto = photoUris.get(info.position); // Set the editor box to have the old text EditText edit = ((EditText) getView().findViewById(R.id.directionsedit)); edit.setText(selected); edit.requestFocus(); adapter.remove(selected); photoUris.remove(info.position); // Put a placeholder into the list // TODO Remove the placeholder if saved during editing adapter.insert(getResources().getString(R.string.recipereplacetext), currentDirection); return true; case R.id.ctxmovedowndirection: // "Move Down" option currentDirection = -1; currentPhoto = null; if (info.position < adapter.getCount() - 1) { // We can't move the last direction down adapter.remove(selected); adapter.insert(selected, info.position + 1); photoUris.remove(info.position); photoUris.add(info.position + 1, selectedPhoto); return true; } return false; case R.id.ctxmoveupdirection: // "Move Up" option currentDirection = -1; currentPhoto = null; if (info.position > 0) { // We can't move the first direction up adapter.remove(selected); adapter.insert(selected, info.position - 1); photoUris.remove(info.position); photoUris.add(info.position - 1, selectedPhoto); return true; } return false; case R.id.ctxphotodirection: // "Attach Photo" option attachPhoto(info.position); return true; case R.id.ctxremovephotodirection: // "Remove Photo" option photoUris.set(info.position, null); return true; default: return super.onContextItemSelected(item); } }
From source file:com.akop.bach.fragment.xboxlive.SentMessagesFragment.java
@Override public boolean onContextItemSelected(MenuItem menuItem) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo(); if (info.targetView.getTag() instanceof ViewHolder) { switch (menuItem.getItemId()) { case R.id.menu_delete: AlertDialogFragment frag = AlertDialogFragment.newInstance(DIALOG_CONFIRM, getString(R.string.are_you_sure), getString(R.string.delete_message_q), info.id); frag.setOnOkListener(this); frag.show(getFragmentManager(), "dialog"); return true; }//from w w w . j a v a 2 s.com } return super.onContextItemSelected(menuItem); }