Java Code Examples for android.view.View#showContextMenu()
The following examples show how to use
android.view.View#showContextMenu() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: delion File: ContextMenuHelper.java License: Apache License 2.0 | 6 votes |
/** * Starts showing a context menu for {@code view} based on {@code params}. * @param contentViewCore The {@link ContentViewCore} to show the menu to. * @param params The {@link ContextMenuParams} that indicate what menu items to show. */ @CalledByNative private boolean showContextMenu(ContentViewCore contentViewCore, ContextMenuParams params) { final View view = contentViewCore.getContainerView(); if (view == null || view.getVisibility() != View.VISIBLE || view.getParent() == null) { return false; } mCurrentContextMenuParams = params; view.setOnCreateContextMenuListener(this); if (view.showContextMenu()) { WebContents webContents = contentViewCore.getWebContents(); RecordHistogram.recordBooleanHistogram( "ContextMenu.Shown", webContents != null); if (webContents != null) webContents.onContextMenuOpened(); return true; } return false; }
Example 2
Source Project: AndroidChromium File: ContextMenuHelper.java License: Apache License 2.0 | 6 votes |
/** * Starts showing a context menu for {@code view} based on {@code params}. * @param contentViewCore The {@link ContentViewCore} to show the menu to. * @param params The {@link ContextMenuParams} that indicate what menu items to show. */ @CalledByNative private void showContextMenu(ContentViewCore contentViewCore, ContextMenuParams params) { final View view = contentViewCore.getContainerView(); if (view == null || view.getVisibility() != View.VISIBLE || view.getParent() == null) { return; } mCurrentContextMenuParams = params; view.setOnCreateContextMenuListener(this); if (view.showContextMenu()) { WebContents webContents = contentViewCore.getWebContents(); RecordHistogram.recordBooleanHistogram( "ContextMenu.Shown", webContents != null); } }
Example 3
Source Project: document-viewer File: UIManagerAppCompat.java License: GNU General Public License v3.0 | 5 votes |
public static void openOptionsMenu(final AppCompatActivity activity, final View view) { if (activity.getSupportActionBar().isShowing()) { activity.getSupportActionBar().openOptionsMenu(); } else { view.showContextMenu(); } }
Example 4
Source Project: android_9.0.0_r45 File: Dialog.java License: Apache License 2.0 | 4 votes |
/** * @see Activity#openContextMenu(View) */ public void openContextMenu(@NonNull View view) { view.showContextMenu(); }
Example 5
Source Project: mobile-manager-tool File: MusicListAdapter.java License: MIT License | 4 votes |
@Override public void onClick(View v) { v.showContextMenu(); }
Example 6
Source Project: mobile-manager-tool File: ListViewAdapter.java License: MIT License | 4 votes |
@Override public void onClick(View v) { v.showContextMenu(); }
Example 7
Source Project: mobile-manager-tool File: DragSortListViewAdapter.java License: MIT License | 4 votes |
@Override public void onClick(View v) { v.showContextMenu(); }
Example 8
Source Project: 365browser File: ContextMenuHelper.java License: Apache License 2.0 | 4 votes |
/** * Starts showing a context menu for {@code view} based on {@code params}. * @param contentViewCore The {@link ContentViewCore} to show the menu to. * @param params The {@link ContextMenuParams} that indicate what menu items to show. */ @CalledByNative private void showContextMenu(final ContentViewCore contentViewCore, ContextMenuParams params) { if (params.isFile()) return; View view = contentViewCore.getContainerView(); final WindowAndroid windowAndroid = contentViewCore.getWindowAndroid(); if (view == null || view.getVisibility() != View.VISIBLE || view.getParent() == null || windowAndroid == null || windowAndroid.getActivity().get() == null || mPopulator == null) { return; } mCurrentContextMenuParams = params; mActivity = windowAndroid.getActivity().get(); mCallback = new Callback<Integer>() { @Override public void onResult(Integer result) { mPopulator.onItemSelected( ContextMenuHelper.this, mCurrentContextMenuParams, result); } }; mOnMenuShown = new Runnable() { @Override public void run() { WebContents webContents = contentViewCore.getWebContents(); RecordHistogram.recordBooleanHistogram("ContextMenu.Shown", webContents != null); } }; mOnMenuClosed = new Runnable() { @Override public void run() { if (mNativeContextMenuHelper == 0) return; nativeOnContextMenuClosed(mNativeContextMenuHelper); } }; if (ChromeFeatureList.isEnabled(ChromeFeatureList.CUSTOM_CONTEXT_MENU)) { List<Pair<Integer, List<ContextMenuItem>>> items = mPopulator.buildContextMenu(null, mActivity, mCurrentContextMenuParams); if (items.isEmpty()) { ThreadUtils.postOnUiThread(mOnMenuClosed); return; } final ContextMenuUi menuUi = new TabularContextMenuUi(new Runnable() { @Override public void run() { shareImageDirectly(ShareHelper.getLastShareComponentName()); } }); menuUi.displayMenu(mActivity, mCurrentContextMenuParams, items, mCallback, mOnMenuShown, mOnMenuClosed); if (mCurrentContextMenuParams.isImage()) { getThumbnail(new Callback<Bitmap>() { @Override public void onResult(Bitmap result) { ((TabularContextMenuUi) menuUi).onImageThumbnailRetrieved(result); } }); } return; } // The Platform Context Menu requires the listener within this hepler since this helper and // provides context menu for us to show. view.setOnCreateContextMenuListener(this); if (view.showContextMenu()) { mOnMenuShown.run(); windowAndroid.addContextMenuCloseListener(new OnCloseContextMenuListener() { @Override public void onContextMenuClosed() { mOnMenuClosed.run(); windowAndroid.removeContextMenuCloseListener(this); } }); } }
Example 9
Source Project: 365browser File: BrowserActionsContextMenuHelper.java License: Apache License 2.0 | 4 votes |
@Override public void onViewAttachedToWindow(View view) { if (view.showContextMenu()) { mOnMenuShown.run(); } }
Example 10
Source Project: PreferenceFragment File: Dialog.java License: Apache License 2.0 | 4 votes |
/** * @see Activity#openContextMenu(View) */ public void openContextMenu(View view) { view.showContextMenu(); }