List of usage examples for android.view ContextMenu findItem
public MenuItem findItem(int id);
From source file:com.android.browser.BookmarksPageCallbacks.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { BookmarkContextMenuInfo info = (BookmarkContextMenuInfo) menuInfo; BrowserBookmarksAdapter adapter = getChildAdapter(info.groupPosition); Cursor cursor = adapter.getItem(info.childPosition); if (!canEdit(cursor)) { return;//from w w w .j ava 2 s . co m } boolean isFolder = cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0; final Activity activity = getActivity(); MenuInflater inflater = activity.getMenuInflater(); inflater.inflate(R.menu.bookmarkscontext, menu); if (isFolder) { menu.setGroupVisible(R.id.FOLDER_CONTEXT_MENU, true); } else { menu.setGroupVisible(R.id.BOOKMARK_CONTEXT_MENU, true); if (mDisableNewWindow) { menu.findItem(R.id.new_window_context_menu_id).setVisible(false); } } BookmarkItem header = new BookmarkItem(activity); header.setEnableScrolling(true); populateBookmarkItem(cursor, header, isFolder); menu.setHeaderView(header); int count = menu.size(); for (int i = 0; i < count; i++) { menu.getItem(i).setOnMenuItemClickListener(mContextItemClickListener); } }
From source file:com.baohume.browser.BookmarksPageCallbacks.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { BookmarkExpandableView.BookmarkContextMenuInfo info = (BookmarkExpandableView.BookmarkContextMenuInfo) menuInfo; BrowserBookmarksAdapter adapter = getChildAdapter(info.groupPosition); Cursor cursor = adapter.getItem(info.childPosition); if (!canEdit(cursor)) { return;//from w w w. ja v a 2 s .c o m } boolean isFolder = cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0; final Activity activity = getActivity(); MenuInflater inflater = activity.getMenuInflater(); inflater.inflate(R.menu.bookmarkscontext, menu); if (isFolder) { menu.setGroupVisible(R.id.FOLDER_CONTEXT_MENU, true); } else { menu.setGroupVisible(R.id.BOOKMARK_CONTEXT_MENU, true); if (mDisableNewWindow) { menu.findItem(R.id.new_window_context_menu_id).setVisible(false); } } BookmarkItem header = new BookmarkItem(activity); header.setEnableScrolling(true); populateBookmarkItem(cursor, header, isFolder); menu.setHeaderView(header); int count = menu.size(); for (int i = 0; i < count; i++) { menu.getItem(i).setOnMenuItemClickListener(mContextItemClickListener); } }
From source file:free.yhc.feeder.ChannelListFragment.java
public void onCreateContextMenu2(ContextMenu menu, View v, ContextMenuInfo menuInfo) { eAssert(mPrimary);// w ww.j av a 2 s. c o m MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.channel_context, menu); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; if (getAdapter().isLoadingItem(info.position)) return; long dbId = getAdapter().getItemInfo_cid(info.position); RTTask.TaskState updateState = mRtt.getState(dbId, RTTask.Action.UPDATE); if (RTTask.TaskState.RUNNING == updateState || RTTask.TaskState.READY == updateState || RTTask.TaskState.CANCELING == updateState) { menu.findItem(R.id.delete).setEnabled(false); menu.findItem(R.id.pick_icon).setEnabled(false); /* full update is useless at this moment. Codes are left for history tracking menu.findItem(R.id.full_update).setEnabled(false); */ } if (mRtt.getItemsDownloading(dbId).length > 0) { menu.findItem(R.id.delete).setEnabled(false); menu.findItem(R.id.delete_dnfile).setEnabled(false); } }
From source file:com.owncloud.android.ui.fragment.OCFileListFragment.java
/** * {@inheritDoc}/*ww w . ja v a 2 s . c om*/ */ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { Bundle args = getArguments(); boolean allowContextualActions = (args == null) ? true : args.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS, true); if (allowContextualActions) { MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.file_actions_menu, menu); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; OCFile targetFile = (OCFile) mAdapter.getItem(info.position); if (mContainerActivity.getStorageManager() != null) { FileMenuFilter mf = new FileMenuFilter(targetFile, mContainerActivity.getStorageManager().getAccount(), mContainerActivity, getActivity()); mf.filter(menu); } /// TODO break this direct dependency on FileDisplayActivity... if possible MenuItem item = menu.findItem(R.id.action_open_file_with); FileFragment frag = ((FileDisplayActivity) getActivity()).getSecondFragment(); if (frag != null && frag instanceof FileDetailFragment && frag.getFile().getFileId() == targetFile.getFileId()) { item = menu.findItem(R.id.action_see_details); if (item != null) { item.setVisible(false); item.setEnabled(false); } } } }
From source file:com.borqs.browser.combo.BookmarksPageCallbacks.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { BookmarkContextMenuInfo info = (BookmarkContextMenuInfo) menuInfo; BrowserBookmarksAdapter adapter = getChildAdapter(info.groupPosition); Cursor cursor = adapter.getItem(info.childPosition); if (!canEdit(cursor)) { return;/*from w w w . j a v a 2 s .c o m*/ } boolean isFolder = cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0; final Activity activity = this; MenuInflater inflater = activity.getMenuInflater(); inflater.inflate(R.menu.bookmarkscontext, menu); if (isFolder) { menu.setGroupVisible(R.id.FOLDER_CONTEXT_MENU, true); } else { menu.setGroupVisible(R.id.BOOKMARK_CONTEXT_MENU, true); if (mDisableNewWindow) { menu.findItem(R.id.new_window_context_menu_id).setVisible(false); } } BookmarkItem header = new BookmarkItem(activity); header.setEnableScrolling(true); populateBookmarkItem(cursor, header, isFolder); menu.setHeaderView(header); int count = menu.size(); for (int i = 0; i < count; i++) { menu.getItem(i).setOnMenuItemClickListener(mContextItemClickListener); } }
From source file:org.gateshipone.odyssey.activities.OdysseyMainActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (v.getId() == R.id.list_linear_listview && mNowPlayingDragStatus == DRAG_STATUS.DRAGGED_UP) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.context_menu_current_playlist, menu); try {//w w w .ja v a2 s. c om if (mServiceConnection.getPBS() .getCurrentIndex() == ((AdapterView.AdapterContextMenuInfo) menuInfo).position) { menu.findItem(R.id.view_current_playlist_action_playnext).setVisible(false); } } catch (RemoteException e) { e.printStackTrace(); } } }
From source file:edu.mit.mobile.android.locast.itineraries.ItineraryDetail.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // only enable this menu if we can actually edit things. if (Constants.CAN_CREATE_CASTS) { AdapterView.AdapterContextMenuInfo info; try {// w ww .java2s. c om info = (AdapterView.AdapterContextMenuInfo) menuInfo; } catch (final ClassCastException e) { Log.e(TAG, "bad menuInfo", e); return; } // XXX the "- 1" below is due to having a header. I'm not sure where this is supposed to // be handled. final Cursor c = (Cursor) mCastAdapter.getItem(info.position - 1); if (c == null) { return; } // load the base menus. final MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.cast_context, menu); menuInflater.inflate(R.menu.cast_options, menu); menu.setHeaderTitle(c.getString(c.getColumnIndex(Cast._TITLE))); final boolean canEdit = Cast.canEdit(this, c); menu.findItem(R.id.cast_edit).setVisible(canEdit); menu.findItem(R.id.cast_delete).setVisible(canEdit); } else { super.onCreateContextMenu(menu, v, menuInfo); } }
From source file:com.googlecode.networklog.LogFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.layout.log_context_menu, menu); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; ListItem listItem = listData.get(info.position); if (NetworkLogService.toastBlockedApps.get(listItem.app.packageName) != null) { menu.findItem(R.id.log_toggle_app_notifications).setTitle(R.string.enable_notifications); } else {/*from ww w.ja va 2s. co m*/ menu.findItem(R.id.log_toggle_app_notifications).setTitle(R.string.disable_notifications); } if (NetworkLogService.blockedApps.get(listItem.app.packageName) != null) { menu.findItem(R.id.log_toggle_app_logging).setTitle(R.string.unblock_app); } else { menu.findItem(R.id.log_toggle_app_logging).setTitle(R.string.block_app); } }
From source file:org.mozilla.gecko.home.TopSitesPanel.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { if (menuInfo == null) { return;/*from ww w . j av a 2 s. c om*/ } if (!(menuInfo instanceof TopSitesGridContextMenuInfo)) { // Long pressed item was not a Top Sites GridView item. Superclass // can handle this. super.onCreateContextMenu(menu, view, menuInfo); return; } // Long pressed item was a Top Sites GridView item, handle it. MenuInflater inflater = new MenuInflater(view.getContext()); inflater.inflate(R.menu.home_contextmenu, menu); // Hide unused menu items. menu.findItem(R.id.home_edit_bookmark).setVisible(false); TopSitesGridContextMenuInfo info = (TopSitesGridContextMenuInfo) menuInfo; menu.setHeaderTitle(info.getDisplayTitle()); if (info.type != TopSites.TYPE_BLANK) { if (info.type == TopSites.TYPE_PINNED) { menu.findItem(R.id.top_sites_pin).setVisible(false); } else { menu.findItem(R.id.top_sites_unpin).setVisible(false); } } else { menu.findItem(R.id.home_open_new_tab).setVisible(false); menu.findItem(R.id.home_open_private_tab).setVisible(false); menu.findItem(R.id.top_sites_pin).setVisible(false); menu.findItem(R.id.top_sites_unpin).setVisible(false); } if (!StringUtils.isShareableUrl(info.url) || GeckoProfile.get(getActivity()).inGuestMode()) { menu.findItem(R.id.home_share).setVisible(false); } if (!RestrictedProfiles.isAllowed(view.getContext(), Restriction.DISALLOW_PRIVATE_BROWSING)) { menu.findItem(R.id.home_open_private_tab).setVisible(false); } }
From source file:hku.fyp14017.blencode.ui.fragment.SoundFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); if (SoundController.getInstance().isSoundPlaying(mediaPlayer)) { SoundController.getInstance().stopSoundAndUpdateList(mediaPlayer, soundInfoList, adapter); }// w w w. j a va2s .co m selectedSoundInfo = adapter.getItem(selectedSoundPosition); menu.setHeaderTitle(selectedSoundInfo.getTitle()); adapter.addCheckedItem(((AdapterContextMenuInfo) menuInfo).position); getSherlockActivity().getMenuInflater().inflate(hku.fyp14017.blencode.R.menu.context_menu_default, menu); menu.findItem(hku.fyp14017.blencode.R.id.context_menu_copy).setVisible(true); menu.findItem(hku.fyp14017.blencode.R.id.context_menu_unpacking).setVisible(false); }