List of usage examples for android.view ContextMenu findItem
public MenuItem findItem(int id);
From source file:org.dvbviewer.controller.ui.fragments.ChannelEpg.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (getUserVisibleHint()) { super.onCreateContextMenu(menu, v, menuInfo); getActivity().getMenuInflater().inflate(R.menu.context_menu_epg, menu); MenuItem switchItem = menu.findItem(R.id.menuSwitch) .setVisible(URLUtil.isValidUrl(ServerConsts.DVBVIEWER_URL)); switchItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override/*from ww w . j a v a 2 s. c o m*/ public boolean onMenuItemClick(MenuItem item) { if (getUserVisibleHint()) { String switchRequest = ServerConsts.URL_SWITCH_COMMAND + mCHannel.getPosition(); DVBViewerCommand command = new DVBViewerCommand(switchRequest); Thread exexuterTHread = new Thread(command); exexuterTHread.start(); return true; } return false; } }); /** * Damn Hack for Tablets, onContextItemSelected is not called, * But the Dialog appears... */ if (UIUtils.isTablet(getActivity())) { menu.findItem(R.id.menuTimer).setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (getUserVisibleHint()) { Cursor c = mAdapter.getCursor(); c.moveToPosition(selectedPosition); Timer timer = cursorToTimer(c); TimerDetails timerdetails = TimerDetails.newInstance(); Bundle args = new Bundle(); args.putString(TimerDetails.EXTRA_TITLE, timer.getTitle()); args.putString(TimerDetails.EXTRA_CHANNEL_NAME, timer.getChannelName()); args.putLong(TimerDetails.EXTRA_CHANNEL_ID, timer.getChannelId()); args.putLong(TimerDetails.EXTRA_START, timer.getStart().getTime()); args.putLong(TimerDetails.EXTRA_END, timer.getEnd().getTime()); timerdetails.setArguments(args); timerdetails.show(getSherlockActivity().getSupportFragmentManager(), TimerDetails.class.getName()); return true; } return false; } }); } } }
From source file:org.peercast.core.PeerCastFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; int type = ExpandableListView.getPackedPositionType(info.packedPosition); int gPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); int cPos = ExpandableListView.getPackedPositionChild(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { // ??//w ww. j a v a 2 s . c o m getActivity().getMenuInflater().inflate(R.menu.channel_context_menu, menu); Channel ch = mListAdapter.getGroup(gPos); menu.setHeaderTitle(ch.getInfo().getName()); MenuItem mKeep = menu.findItem(R.id.menu_ch_keep); mKeep.setChecked(ch.isStayConnected()); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { // getActivity().getMenuInflater().inflate(R.menu.servent_context_menu, menu); Servent svt = mListAdapter.getChild(gPos, cPos); menu.setHeaderTitle(svt.getHost()); } }
From source file:com.ohso.omgubuntu.BaseFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); android.view.MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.article_row_long_press, menu); AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; Article article = adapter.getItem((int) info.id); if (article.isStarred()) { menu.findItem(R.id.article_row_unstar).setVisible(true); } else {/*from w w w . j a va2s. c o m*/ menu.findItem(R.id.article_row_star).setVisible(true); } if (article.isUnread()) { menu.findItem(R.id.article_mark_as_read).setVisible(true); } else { menu.findItem(R.id.article_mark_as_unread).setVisible(true); } }
From source file:de.androvdr.fragments.ChannelsFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = mActivity.getMenuInflater(); inflater.inflate(R.menu.channels_menu, menu); AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo; menu.setHeaderTitle(mController.getChannelName(mi.position)); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mActivity); if (mSearchTime != 0) { menu.removeItem(R.id.cm_remote); menu.removeItem(R.id.cm_livetv); } else if (!sp.getBoolean("livetv_enabled", false)) { menu.removeItem(R.id.cm_livetv); }/* w w w. j a v a2s . c o m*/ if (Preferences.useInternet && !Preferences.getVdr().extremux) { MenuItem menuitem = menu.findItem(R.id.cm_livetv); if (menuitem != null) menuitem.setEnabled(false); } }
From source file:com.orange.ocara.ui.activity.SetupAuditPathActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; final AuditObject auditObject = auditObjectsAdapter.getItem(info.position); MenuInflater inflater = getMenuInflater(); inflater.inflate(com.orange.ocara.R.menu.audit_objects_context_menu, menu); if (auditObject.getObjectDescription().getChildren().isEmpty()) { menu.findItem(com.orange.ocara.R.id.action_object_characteristics).setVisible(false); } else {/*from w ww.ja v a 2s. co m*/ menu.findItem(com.orange.ocara.R.id.action_object_characteristics).setVisible(true); } }
From source file:org.jitsi.android.gui.contactlist.ContactListFragment.java
/** * Inflates contact context menu./* ww w. j a va 2 s . co m*/ * @param menu the menu to inflate into. * @param inflater the menu inflater. * @param group clicked group index. * @param child clicked contact index. */ private void createContactCtxMenu(ContextMenu menu, MenuInflater inflater, int group, int child) { // Inflate contact list context menu inflater.inflate(R.menu.contact_menu, menu); // Remembers clicked contact clickedContact = ((MetaContact) contactListAdapter.getChild(group, child)); menu.setHeaderTitle(clickedContact.getDisplayName()); // Checks if close chats options should be visible boolean closeChatsVisible = ChatSessionManager.getActiveChat(clickedContact) != null; menu.findItem(R.id.close_chat).setVisible(closeChatsVisible); menu.findItem(R.id.close_all_chats).setVisible(closeChatsVisible); // Checks if the re-request authorization item should be visible Contact contact = clickedContact.getDefaultContact(); if (contact == null) { logger.warn("No default contact for: " + clickedContact); return; } ProtocolProviderService pps = contact.getProtocolProvider(); if (pps == null) { logger.warn("No protocol provider found for: " + contact); return; } OperationSetExtendedAuthorizations authOpSet = pps .getOperationSet(OperationSetExtendedAuthorizations.class); boolean reRequestVisible = false; if (authOpSet != null && authOpSet.getSubscriptionStatus(contact) != null && !authOpSet.getSubscriptionStatus(contact) .equals(OperationSetExtendedAuthorizations.SubscriptionStatus.Subscribed)) { reRequestVisible = true; } menu.findItem(R.id.re_request_auth).setVisible(reRequestVisible); }
From source file:de.syss.MifareClassicTool.Activities.MainMenu.java
/** * Add the menu with the tools./* w w w . ja v a2 s . c o m*/ * It will be shown if the user clicks on "Tools". */ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getMenuInflater(); menu.setHeaderTitle(R.string.dialog_tools_menu_title); menu.setHeaderIcon(android.R.drawable.ic_menu_preferences); inflater.inflate(R.menu.tools, menu); // Enable/Disable tag info tool depending on NFC availability. menu.findItem(R.id.menuMainTagInfo) .setEnabled(Common.hasMifareClassicSupport() && !Common.useAsEditorOnly()); // Enable/Disable diff tool depending on write permissions. menu.findItem(R.id.menuMainDiffTool).setEnabled(Common.hasWritePermissionToExternalStorage(this)); }
From source file:org.mozilla.gecko.home.RemoteTabsBaseFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { if (!(menuInfo instanceof RemoteTabsClientContextMenuInfo)) { // Long pressed item was not a RemoteTabsGroup item. Superclass // can handle this. super.onCreateContextMenu(menu, view, menuInfo); return;/* ww w . ja va 2 s. com*/ } // Long pressed item was a remote client; provide the appropriate menu. final MenuInflater inflater = new MenuInflater(view.getContext()); inflater.inflate(R.menu.home_remote_tabs_client_contextmenu, menu); final RemoteTabsClientContextMenuInfo info = (RemoteTabsClientContextMenuInfo) menuInfo; menu.setHeaderTitle(info.client.name); // Hide unused menu items. final boolean isHidden = sState.isClientHidden(info.client.guid); final MenuItem item = menu .findItem(isHidden ? R.id.home_remote_tabs_hide_client : R.id.home_remote_tabs_show_client); item.setVisible(false); }
From source file:org.dvbviewer.controller.ui.fragments.ChannelList.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); getActivity().getMenuInflater().inflate(R.menu.context_menu_channellist, menu); menu.findItem(R.id.menuSwitch).setVisible(URLUtil.isValidUrl(ServerConsts.DVBVIEWER_URL)); }
From source file:com.gsma.rcs.ri.messaging.OneToOneTalkView.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_1to1_talk_item, menu); menu.findItem(R.id.menu_resend_message).setVisible(false); menu.findItem(R.id.menu_display_content).setVisible(false); menu.findItem(R.id.menu_listen_content).setVisible(false); /* Get the list item position */ AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; Cursor cursor = (Cursor) mAdapter.getItem(info.position); /* Adapt the contextual menu according to the selected item */ int providerId = cursor.getInt(cursor.getColumnIndexOrThrow(HistoryLog.PROVIDER_ID)); String id = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.ID)); Direction direction = Direction.valueOf(cursor.getInt(cursor.getColumnIndexOrThrow(HistoryLog.DIRECTION))); try {// ww w .ja v a2 s . c o m switch (providerId) { case ChatLog.Message.HISTORYLOG_MEMBER_ID: if (Direction.OUTGOING == direction) { ChatLog.Message.Content.Status status = ChatLog.Message.Content.Status .valueOf(cursor.getInt(cursor.getColumnIndexOrThrow(HistoryLog.STATUS))); if (ChatLog.Message.Content.Status.FAILED == status) { String number = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.CONTACT)); if (number != null) { ContactId contact = ContactUtil.formatContact(number); OneToOneChat chat = mChatService.getOneToOneChat(contact); if (chat != null && chat.isAllowedToSendMessage()) { menu.findItem(R.id.menu_resend_message).setVisible(true); } } } } break; case FileTransferLog.HISTORYLOG_MEMBER_ID: String mimeType = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.MIME_TYPE)); FileTransfer.State state = FileTransfer.State .valueOf(cursor.getInt(cursor.getColumnIndexOrThrow(HistoryLog.STATUS))); if (FileTransfer.State.FAILED == state) { FileTransfer transfer = mFileTransferService.getFileTransfer(id); if (transfer != null && transfer.isAllowedToResendTransfer()) { menu.findItem(R.id.menu_resend_message).setVisible(true); } } else if (Utils.isImageType(mimeType)) { if (Direction.OUTGOING == direction) { menu.findItem(R.id.menu_display_content).setVisible(true); } else if (Direction.INCOMING == direction) { Long transferred = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.TRANSFERRED)); Long size = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.FILESIZE)); if (size.equals(transferred)) { menu.findItem(R.id.menu_display_content).setVisible(true); } } } else if (Utils.isAudioType(mimeType)) { if (Direction.OUTGOING == direction) { menu.findItem(R.id.menu_listen_content).setVisible(true); } else if (Direction.INCOMING == direction) { Long transferred = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.TRANSFERRED)); Long size = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.FILESIZE)); if (size.equals(transferred)) { menu.findItem(R.id.menu_listen_content).setVisible(true); } } } break; default: throw new IllegalArgumentException("Invalid provider ID=" + providerId); } } catch (RcsServiceNotAvailableException e) { menu.findItem(R.id.menu_resend_message).setVisible(false); } catch (RcsGenericException | RcsPersistentStorageException e) { menu.findItem(R.id.menu_resend_message).setVisible(false); showException(e); } }