Java Code Examples for android.widget.PopupMenu#setOnDismissListener()
The following examples show how to use
android.widget.PopupMenu#setOnDismissListener() .
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 File: ZoomAction.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
@Override public void handleClickAction(PlaybackController playbackController, LeanbackOverlayFragment leanbackOverlayFragment, Context context, View view) { PopupMenu zoomMenu = Utils.createPopupMenu(context, view, Gravity.RIGHT); zoomMenu.getMenu().add(0, VideoManager.ZOOM_NORMAL, VideoManager.ZOOM_NORMAL, context.getString(R.string.lbl_normal)).setChecked(playbackController.getZoomMode() == VideoManager.ZOOM_NORMAL); zoomMenu.getMenu().add(0, VideoManager.ZOOM_VERTICAL, VideoManager.ZOOM_VERTICAL, context.getString(R.string.lbl_vertical_stretch)).setChecked(playbackController.getZoomMode() == VideoManager.ZOOM_VERTICAL); zoomMenu.getMenu().add(0, VideoManager.ZOOM_HORIZONTAL, VideoManager.ZOOM_HORIZONTAL, context.getString(R.string.lbl_horizontal_stretch)).setChecked(playbackController.getZoomMode() == VideoManager.ZOOM_HORIZONTAL); zoomMenu.getMenu().add(0, VideoManager.ZOOM_FULL, VideoManager.ZOOM_FULL, context.getString(R.string.lbl_zoom)).setChecked(playbackController.getZoomMode() == VideoManager.ZOOM_FULL); zoomMenu.getMenu().setGroupCheckable(0, true, false); zoomMenu.setOnDismissListener(new PopupMenu.OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { leanbackOverlayFragment.setFading(true); } }); zoomMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { playbackController.setZoom(item.getItemId()); return true; } }); zoomMenu.show(); }
Example 2
Source File: NativeViewHierarchyManager.java From react-native-GPay with MIT License | 6 votes |
/** * Show a {@link PopupMenu}. * * @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this * needs to be the tag of a native view (shadow views can not be anchors) * @param items the menu items as an array of strings * @param success will be called with the position of the selected item as the first argument, or * no arguments if the menu is dismissed */ public synchronized void showPopupMenu(int reactTag, ReadableArray items, Callback success, Callback error) { UiThreadUtil.assertOnUiThread(); View anchor = mTagsToViews.get(reactTag); if (anchor == null) { error.invoke("Can't display popup. Could not find view with tag " + reactTag); return; } mPopupMenu = new PopupMenu(getReactContextForView(reactTag), anchor); Menu menu = mPopupMenu.getMenu(); for (int i = 0; i < items.size(); i++) { menu.add(Menu.NONE, Menu.NONE, i, items.getString(i)); } PopupMenuCallbackHandler handler = new PopupMenuCallbackHandler(success); mPopupMenu.setOnMenuItemClickListener(handler); mPopupMenu.setOnDismissListener(handler); mPopupMenu.show(); }
Example 3
Source File: MyMainActivity.java From a with GNU General Public License v3.0 | 5 votes |
/** * 显示分组菜单 */ private void showBookGroupMenu(View view) { PopupMenu popupMenu = new PopupMenu(this, view); for (int j = 0; j < getResources().getStringArray(R.array.book_group_array).length; j++) { popupMenu.getMenu().add(0, 0, j, getResources().getStringArray(R.array.book_group_array)[j]); } popupMenu.setOnMenuItemClickListener(menuItem -> { upGroup(menuItem.getOrder()); return true; }); popupMenu.setOnDismissListener(popupMenu1 -> updateTabItemIcon(false)); popupMenu.show(); updateTabItemIcon(true); }
Example 4
Source File: MyMainActivity.java From a with GNU General Public License v3.0 | 5 votes |
/** * 显示分组菜单 */ private void showBookGroupMenu(View view) { PopupMenu popupMenu = new PopupMenu(this, view); for (int j = 0; j < getResources().getStringArray(R.array.book_group_array).length; j++) { popupMenu.getMenu().add(0, 0, j, getResources().getStringArray(R.array.book_group_array)[j]); } popupMenu.setOnMenuItemClickListener(menuItem -> { upGroup(menuItem.getOrder()); return true; }); popupMenu.setOnDismissListener(popupMenu1 -> updateTabItemIcon(false)); popupMenu.show(); updateTabItemIcon(true); }
Example 5
Source File: MainActivity.java From MyBookshelf with GNU General Public License v3.0 | 5 votes |
/** * 显示分组菜单 */ private void showBookGroupMenu(View view) { PopupMenu popupMenu = new PopupMenu(this, view); for (int j = 0; j < getResources().getStringArray(R.array.book_group_array).length; j++) { popupMenu.getMenu().add(0, 0, j, getResources().getStringArray(R.array.book_group_array)[j]); } popupMenu.setOnMenuItemClickListener(menuItem -> { upGroup(menuItem.getOrder()); return true; }); popupMenu.setOnDismissListener(popupMenu1 -> updateTabItemIcon(0, false)); popupMenu.show(); updateTabItemIcon(0, true); }
Example 6
Source File: MainActivity.java From trekarta with GNU General Public License v3.0 | 5 votes |
@Override public boolean onGesture(Gesture gesture, MotionEvent event) { mMap.getMapPosition(mMapPosition); // override default behavior to adjust pivot point if (gesture == Gesture.DOUBLE_TAP) { zoomMap(2.0, event.getX() - (mMap.getScreenWidth() >> 1), event.getY() - (mMap.getScreenHeight() >> 1)); return true; } else if (gesture == Gesture.TWO_FINGER_TAP) { zoomMap(0.5, 0f, 0f); return true; } else if (gesture == Gesture.TRIPLE_TAP) { float scale = Configuration.getRememberedScale(); double scaleBy = scale / mMapPosition.getScale(); float x = scaleBy > 1 ? event.getX() - (mMap.getScreenWidth() >> 1) : 0f; float y = scaleBy > 1 ? event.getY() - (mMap.getScreenHeight() >> 1) : 0f; zoomMap(scaleBy, x, y); return true; } else if (gesture == Gesture.LONG_PRESS) { if (!mMap.getEventLayer().moveEnabled() || !mObjectInteractionEnabled) return true; mViews.popupAnchor.setX(event.getX() + mFingerTipSize); mViews.popupAnchor.setY(event.getY() - mFingerTipSize); mSelectedPoint = mMap.viewport().fromScreenPoint(event.getX(), event.getY()); showMarker(mSelectedPoint, null, false); PopupMenu popup = new PopupMenu(this, mViews.popupAnchor); popup.inflate(R.menu.context_menu_map); Menu popupMenu = popup.getMenu(); if (mLocationState == LocationState.DISABLED || mLocationState == LocationState.SEARCHING || mLocationService == null || !isOnline()) popupMenu.removeItem(R.id.actionFindRouteHere); if ((int) Configuration.getRememberedScale() == (int) mMapPosition.getScale()) popupMenu.removeItem(R.id.actionRememberScale); if (mLocationState != LocationState.TRACK || mAutoTilt == -1f || MathUtils.equals(mAutoTilt, mMapPosition.getTilt())) popupMenu.removeItem(R.id.actionRememberTilt); popup.setOnMenuItemClickListener(this); popup.setOnDismissListener(menu -> removeMarker()); popup.show(); return true; } return false; }
Example 7
Source File: MainActivity.java From MyBookshelf with GNU General Public License v3.0 | 4 votes |
/** * 显示发现菜单 */ private void showFindMenu(View view) { PopupMenu popupMenu = new PopupMenu(this, view); popupMenu.getMenu().add(0, 0, 0, getString(R.string.switch_display_style)); popupMenu.getMenu().add(0, 0, 1, getString(R.string.clear_find_cache)); boolean findTypeIsFlexBox = preferences.getBoolean("findTypeIsFlexBox", true); boolean showFindLeftView = preferences.getBoolean("showFindLeftView", true); if (findTypeIsFlexBox) { popupMenu.getMenu().add(0, 0, 2, showFindLeftView ? "隐藏左侧栏" : "显示左侧栏"); } popupMenu.setOnMenuItemClickListener(menuItem -> { FindBookFragment findBookFragment = getFindFragment(); switch (menuItem.getOrder()) { case 0: preferences.edit() .putBoolean("findTypeIsFlexBox", !findTypeIsFlexBox) .apply(); if (findBookFragment != null) { findBookFragment.upStyle(); } break; case 1: ACache.get(this, "findCache").clear(); if (findBookFragment != null) { findBookFragment.refreshData(); } break; case 2: preferences.edit() .putBoolean("showFindLeftView", !showFindLeftView) .apply(); if (findBookFragment != null) { findBookFragment.upUI(); } break; } return true; }); popupMenu.setOnDismissListener(popupMenu1 -> updateTabItemIcon(1, false)); popupMenu.show(); updateTabItemIcon(1, true); }