android.view.View#showContextMenu ( )源码实例Demo

下面列出了android.view.View#showContextMenu ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: delion   文件: ContextMenuHelper.java
/**
 * 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;
}
 
源代码2 项目: AndroidChromium   文件: ContextMenuHelper.java
/**
 * 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);
    }
}
 
源代码3 项目: document-viewer   文件: UIManagerAppCompat.java
public static void openOptionsMenu(final AppCompatActivity activity, final View view) {
    if (activity.getSupportActionBar().isShowing()) {
        activity.getSupportActionBar().openOptionsMenu();
    } else {
        view.showContextMenu();
    }
}
 
源代码4 项目: android_9.0.0_r45   文件: Dialog.java
/**
 * @see Activity#openContextMenu(View)
 */
public void openContextMenu(@NonNull View view) {
    view.showContextMenu();
}
 
源代码5 项目: mobile-manager-tool   文件: MusicListAdapter.java
@Override
public void onClick(View v) {
    v.showContextMenu();
}
 
源代码6 项目: mobile-manager-tool   文件: ListViewAdapter.java
@Override
public void onClick(View v) {
    v.showContextMenu();
}
 
@Override
public void onClick(View v) {
    v.showContextMenu();
}
 
源代码8 项目: 365browser   文件: ContextMenuHelper.java
/**
 * 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);
            }
        });
    }
}
 
@Override
public void onViewAttachedToWindow(View view) {
    if (view.showContextMenu()) {
        mOnMenuShown.run();
    }
}
 
源代码10 项目: PreferenceFragment   文件: Dialog.java
/**
 * @see Activity#openContextMenu(View)
 */
public void openContextMenu(View view) {
    view.showContextMenu();
}
 
 方法所在类
 同类方法