List of usage examples for android.view ContextMenu size
public int size();
From source file:com.todoroo.astrid.core.CustomFilterActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (menu.size() > 0) menu.clear();// w w w .ja v a2s. c o m // view holder if (v.getTag() != null) { adapter.onCreateContextMenu(menu, v); } }
From source file:com.workingagenda.democracydroid.Adapters.ViewHolders.EpisodeViewHolder.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { MenuInflater inflater = new MenuInflater(itemView.getContext()); menu.setHeaderTitle("Democracy Now!"); inflater.inflate(R.menu.context_menu, menu); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(itemView.getContext()); int DEFAULT_STREAM = Integer.parseInt(preferences.getString("stream_preference", "0")); // 0=video int DEFAULT_OPEN = Integer.parseInt(preferences.getString("open_preference", "0")); // 0 = within this app if (DEFAULT_STREAM == 0) menu.getItem(2).setTitle("Stream Audio"); else//ww w .j a va 2s. c om menu.getItem(2).setTitle("Stream Video"); if (DEFAULT_OPEN == 0) menu.getItem(3).setTitle("Stream in Another App"); else menu.getItem(3).setTitle("Stream in This App"); for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setOnMenuItemClickListener(this); } }
From source file:com.todoroo.astrid.activity.FilterListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; Filter item = adapter.getItem(info.position); android.view.MenuItem menuItem; if (item instanceof Filter) { Filter filter = (Filter) item; menuItem = menu.add(0, CONTEXT_MENU_SHORTCUT, 0, R.string.FLA_context_shortcut); menuItem.setIntent(ShortcutActivity.createIntent(filter)); }/*from w w w . j a va2 s. com*/ for (int i = 0; i < item.contextMenuLabels.length; i++) { if (item.contextMenuIntents.length <= i) break; menuItem = menu.add(0, CONTEXT_MENU_INTENT, 0, item.contextMenuLabels[i]); menuItem.setIntent(item.contextMenuIntents[i]); } if (menu.size() > 0) menu.setHeaderTitle(item.listingTitle); }
From source file:org.mozilla.mozstumbler.client.serialize.KMLFragment.java
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); final ListView list = (ListView) v; final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; final int position = info.position; final Object object = list.getAdapter().getItem(position); menu.add(R.string.load_file);/*from ww w . j av a 2s .co m*/ menu.add(R.string.share_file); menu.add(R.string.delete_file); menu.add(R.string.delete_all); MenuItem.OnMenuItemClickListener listener = new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { contextItemSelected(item, (object == null) ? null : object.toString()); if (mLoadFileDialog != null && mLoadFileDialog.isShowing()) { mLoadFileDialog.dismiss(); } return false; } }; for (int i = 0, n = menu.size(); i < n; i++) menu.getItem(i).setOnMenuItemClickListener(listener); }
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;/* ww 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: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 ww . ja v a 2 s . c om } 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.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;/* ww w . j a v a 2s .c om*/ } 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:com.fsck.k9.activity.Accounts.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.setHeaderTitle(R.string.accounts_context_menu_title); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; BaseAccount account = mAdapter.getItem(info.position); if ((account instanceof Account) && !((Account) account).isEnabled()) { getMenuInflater().inflate(R.menu.disabled_accounts_context, menu); } else {/*from w ww. j av a 2s .c o m*/ getMenuInflater().inflate(R.menu.accounts_context, menu); } if (account instanceof SearchAccount) { for (int i = 0; i < menu.size(); i++) { android.view.MenuItem item = menu.getItem(i); item.setVisible(false); } } else { EnumSet<ACCOUNT_LOCATION> accountLocation = accountLocation(account); if (accountLocation.contains(ACCOUNT_LOCATION.TOP)) { menu.findItem(R.id.move_up).setEnabled(false); } else { menu.findItem(R.id.move_up).setEnabled(true); } if (accountLocation.contains(ACCOUNT_LOCATION.BOTTOM)) { menu.findItem(R.id.move_down).setEnabled(false); } else { menu.findItem(R.id.move_down).setEnabled(true); } } }
From source file:com.bernard.beaconportal.activities.activity.MessageList.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; if (v == getListView()) { if (info.position > mAdapter_Accounts.getCount() + 5) { getMenuInflater().inflate(R.menu.folder_context, menu); FolderInfoHolder folder = (FolderInfoHolder) mAdapter .getItem(info.position - (mAdapter_Accounts.getCount() + 6)); menu.setHeaderTitle(folder.displayName); } else if (info.position < mAdapter_Accounts.getCount()) { menu.setHeaderTitle(R.string.accounts_context_menu_title); if (mAdapter_Accounts == null) { Log.d("info =", "mAdapter_Accounts = null"); }/* ww w . j a v a 2s. com*/ BaseAccount account = (BaseAccount) mergeadapter.getItem(info.position); if ((account instanceof Account) && !((Account) account).isEnabled()) { getMenuInflater().inflate(R.menu.disabled_accounts_context, menu); } else { getMenuInflater().inflate(R.menu.accounts_context, menu); } if (account instanceof SearchAccount) { for (int i = 0; i < menu.size(); i++) { android.view.MenuItem item = menu.getItem(i); item.setVisible(false); } } else { EnumSet<ACCOUNT_LOCATION> accountLocation = accountLocation(account); if (accountLocation.contains(ACCOUNT_LOCATION.TOP)) { menu.findItem(R.id.move_up).setEnabled(false); } else { menu.findItem(R.id.move_up).setEnabled(true); } if (accountLocation.contains(ACCOUNT_LOCATION.BOTTOM)) { menu.findItem(R.id.move_down).setEnabled(false); } else { menu.findItem(R.id.move_down).setEnabled(true); } } } } }