List of usage examples for android.widget PopupMenu PopupMenu
public PopupMenu(Context context, View anchor)
From source file:de.spiritcroc.ownlog.ui.view.EditTagsView.java
private void showAddTagMenu() { // Ensure we have a tags provider if (mTagsProvider == null) { Log.e(TAG, "Cannot load tags: no tags provider"); return;/*from w ww. ja v a 2s . c om*/ } // Use context from activity instead of getContext() to separate popup from // this view's theme (padding etc.) PopupMenu popupMenu = new PopupMenu(mTagsProvider.getActivity(), mAddTagButton); Menu menu = popupMenu.getMenu(); final List<TagItem> availableTags = mTagsProvider.getAvailableTags(); final List<TagItem> setTags = mTagsProvider.getSetTags(); final HashMap<String, TagItem> tagMap = new HashMap<>(); for (TagItem tag : availableTags) { if (mAvailableTagsFilter.shouldShowTag(tag)) { menu.add(tag.name); tagMap.put(tag.name, tag); } } menu.add(R.string.edit_log_tags_add_new); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { String name = menuItem.getTitle().toString(); if (tagMap.containsKey(name)) { setTags.add(tagMap.get(name)); mTagsProvider.onSetTagsChanged(); updateContent(); } else { new TagItemEditFragment().show(mTagsProvider.getActivity().getFragmentManager(), "TagItemEditFragment"); } return false; } }); popupMenu.show(); }
From source file:org.messic.android.smartphone.activities.main.fragments.downloaded.DownloadedFragment.java
@Override public void onMoreAction(View caller, View anchor, final DownloadedAlbumViewHolder holder) { // Creating the instance of PopupMenu PopupMenu popup = new PopupMenu(DownloadedFragment.this.getActivity(), anchor); // Inflating the Popup using xml file popup.getMenuInflater().inflate(R.menu.activity_downloaded_menu_album, popup.getMenu()); // registering popup with OnMenuItemClickListener popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_album_item_remove: removeAlbum(holder.album, holder); break; case R.id.menu_album_item_play: presenter.playAction(holder.album); break; case R.id.menu_album_item_playnow: presenter.longPlayAction(holder.album); break; }//from w w w . j av a 2 s. co m return true; } }); popup.show();// showing popup menu }
From source file:freed.viewer.gridview.GridViewFragment.java
private void showFileSelectionPopup(View v) { PopupMenu popup = new PopupMenu(getContext(), v); popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override/*from w w w . j a v a 2 s .co m*/ public boolean onMenuItemClick(MenuItem item) { int i = item.getItemId(); if (i == id.all) { filetypeButton.setText(string.ALL); formatsToShow = FormatTypes.all; } else if (i == id.raw) { filetypeButton.setText("RAW"); formatsToShow = FormatTypes.raw; } else if (i == id.bayer) { filetypeButton.setText("BAYER"); formatsToShow = FormatTypes.raw; } else if (i == id.dng) { filetypeButton.setText("DNG"); formatsToShow = FormatTypes.dng; } else if (i == id.jps) { filetypeButton.setText("JPS"); formatsToShow = FormatTypes.jps; } else if (i == id.jpg) { filetypeButton.setText("JPG"); formatsToShow = FormatTypes.jpg; } else if (i == id.mp4) { filetypeButton.setText("MP4"); formatsToShow = FormatTypes.mp4; } //if (savedInstanceFilePath != null) viewerActivityInterface.LoadFolder(folderToShow, formatsToShow); return false; } }); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(menu.filetypepopupmenu, popup.getMenu()); popup.show(); }
From source file:free.yhc.feeder.ChannelListActivity.java
private void onOpt_addChannel_youtube(final View anchor) { PopupMenu popup = new PopupMenu(this, anchor); popup.getMenuInflater().inflate(R.menu.popup_addchannel_youtube, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override/* w w w . j a v a 2 s. c om*/ public boolean onMenuItemClick(MenuItem item) { onOpt_addChannel_youtubeEditDiag(item); return true; } }); popup.show(); }
From source file:org.xbmc.kore.ui.SongsListFragment.java
private void showPopupMenu(View v) { ViewHolder viewHolder = (ViewHolder) v.getTag(); final PlaylistType.Item playListItem = new PlaylistType.Item(); playListItem.songid = viewHolder.songId; final PopupMenu popupMenu = new PopupMenu(getActivity(), v); popupMenu.getMenuInflater().inflate(R.menu.musiclist_item, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override//from w ww. ja va2 s .com public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_play: MediaPlayerUtils.play(SongsListFragment.this, playListItem); return true; case R.id.action_queue: MediaPlayerUtils.queue(SongsListFragment.this, playListItem, PlaylistType.GetPlaylistsReturnType.AUDIO); return true; } return false; } }); popupMenu.show(); }
From source file:com.audiokernel.euphonyrmt.MainMenuActivity.java
private PopupMenu initializeHeaderOverflowPopup(final View headerOverflowMenu) { final PopupMenu resultPopupMenu; if (headerOverflowMenu == null) { resultPopupMenu = null;/* w ww. j a v a 2s .c o m*/ } else { final PopupMenu popupMenu = new PopupMenu(this, headerOverflowMenu); popupMenu.getMenuInflater().inflate(R.menu.mpd_mainmenu, popupMenu.getMenu()); popupMenu.getMenuInflater().inflate(R.menu.mpd_playlistmenu, popupMenu.getMenu()); popupMenu.getMenu().removeItem(R.id.PLM_EditPL); popupMenu.setOnMenuItemClickListener(this); headerOverflowMenu.setOnTouchListener(PopupMenuCompat.getDragToOpenListener(popupMenu)); headerOverflowMenu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { if (mSlidingLayout != null && mSlidingLayout.isPanelExpanded()) { prepareNowPlayingMenu(popupMenu.getMenu()); popupMenu.show(); } } }); resultPopupMenu = popupMenu; } return resultPopupMenu; }
From source file:de.aw.monma.actions.FragmentWPList.java
/** * Bei Click wird das contextmenu gezeigt. In den jeweiligen extras sind folgende Informationen * enthalten: WPID, AMOUNT, WPNAME des gewaehlten Wertpapiers. *//* ww w . j a v a 2 s .co m*/ @Override public void onRecyclerItemClick(View view, int position, WertpapierListItem item) { super.onRecyclerItemClick(view, position, item); Intent intent = new Intent(); intent.putExtra(WPID, item.getID()); intent.putExtra(WPNAME, item.getWPName()); intent.putExtra(ACCOUNTID, NOID); intent.putExtra(AMOUNT, item.getGewinn()); PopupMenu popUpMenu = new PopupMenu(getActivity(), view); popUpMenu.inflate(R.menu.context_fragment_wpuebersicht); popUpMenu.inflate(R.menu.context_fragment_wpliste); Menu menu = popUpMenu.getMenu(); for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setIntent(intent); } popUpMenu.setOnMenuItemClickListener(this); popUpMenu.show(); }
From source file:net.lp.actionbarpoirot.actions.UiAction.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void addActionItemToLeftNavBar(C context, ActivityHelper activityHelper) { if (UiUtilities.isGoogleTV(context.getApplicationContext())) { try {/* w ww .j av a 2s. co m*/ final LeftNavBar leftNavBar = ((LeftNavBar) ((ActivityHelperHoneycomb) activityHelper) .getActionBar()); final PopupMenu tempMenu = new PopupMenu(context, leftNavBar.getCustomView());// TODO: Should not use // MenuItem and // onCreateOptionsMenu, but // build an own stack of // methods for the // LeftNavBar. leftNavBar.addActionItem(onCreateOptionsMenu(tempMenu.getMenu(), context), this); } catch (ClassCastException ce) { if (PoirotWindow.DEBUG) Log.d(TAG, "ClassCastException with LeftNavBar", ce); } } }
From source file:systems.soapbox.ombuds.client.ui.WalletTransactionsFragment.java
@Override public void onTransactionMenuClick(final View view, final Transaction tx) { final boolean txSent = tx.getValue(wallet).signum() < 0; final Address txAddress = txSent ? WalletUtils.getToAddressOfSent(tx, wallet) : WalletUtils.getWalletAddressOfReceived(tx, wallet); final byte[] txSerialized = tx.unsafeBitcoinSerialize(); final boolean txRotation = tx.getPurpose() == Purpose.KEY_ROTATION; final PopupMenu popupMenu = new PopupMenu(activity, view); popupMenu.inflate(R.menu.wallet_transactions_context); final MenuItem editAddressMenuItem = popupMenu.getMenu() .findItem(R.id.wallet_transactions_context_edit_address); if (!txRotation && txAddress != null) { editAddressMenuItem.setVisible(true); final boolean isAdd = AddressBookProvider.resolveLabel(activity, txAddress.toString()) == null; final boolean isOwn = wallet.isPubKeyHashMine(txAddress.getHash160()); if (isOwn) editAddressMenuItem.setTitle(isAdd ? R.string.edit_address_book_entry_dialog_title_add_receive : R.string.edit_address_book_entry_dialog_title_edit_receive); else//from ww w . j a va 2 s . c o m editAddressMenuItem.setTitle(isAdd ? R.string.edit_address_book_entry_dialog_title_add : R.string.edit_address_book_entry_dialog_title_edit); } else { editAddressMenuItem.setVisible(false); } popupMenu.getMenu().findItem(R.id.wallet_transactions_context_show_qr) .setVisible(!txRotation && txSerialized.length < SHOW_QR_THRESHOLD_BYTES); popupMenu.getMenu().findItem(R.id.wallet_transactions_context_raise_fee) .setVisible(RaiseFeeDialogFragment.feeCanBeRaised(wallet, tx)); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case R.id.wallet_transactions_context_edit_address: handleEditAddress(tx); return true; case R.id.wallet_transactions_context_show_qr: handleShowQr(); return true; case R.id.wallet_transactions_context_browse: if (!txRotation) startActivity(new Intent(Intent.ACTION_VIEW, Uri.withAppendedPath(config.getBlockExplorer(), "tx/" + tx.getHashAsString()))); else startActivity(new Intent(Intent.ACTION_VIEW, KEY_ROTATION_URI)); return true; case R.id.wallet_transactions_context_raise_fee: RaiseFeeDialogFragment.show(getFragmentManager(), tx); return true; } return false; } private void handleEditAddress(final Transaction tx) { EditAddressBookEntryFragment.edit(getFragmentManager(), txAddress); } private void handleShowQr() { final int size = getResources().getDimensionPixelSize(R.dimen.bitmap_dialog_qr_size); final Bitmap qrCodeBitmap = Qr.bitmap(Qr.encodeCompressBinary(txSerialized), size); BitmapFragment.show(getFragmentManager(), qrCodeBitmap); } }); popupMenu.show(); }
From source file:com.owncloud.android.ui.fragment.FileDetailSharingFragment.java
@OnClick(R.id.overflow_menu_share_link) public void showLinkOverflowMenu() { Context context = getContext(); if (context != null && ThemeUtils.themingEnabled(context)) { // use grey as fallback for elements where custom theming is not available context.getTheme().applyStyle(R.style.FallbackThemingTheme, true); } else {/*from w w w .j av a 2 s . c o m*/ context = getActivity(); } PopupMenu popup = new PopupMenu(context, overflowMenuShareLink); popup.inflate(R.menu.file_detail_sharing_link_menu); prepareOptionsMenu(popup.getMenu()); popup.setOnMenuItemClickListener(this::optionsItemSelected); popup.show(); }