Search in sources :

Example 96 with PopupMenu

use of android.support.v7.widget.PopupMenu in project apps-android-wikipedia by wikimedia.

the class StaticCardView method showOverflowMenu.

private void showOverflowMenu(View anchorView) {
    PopupMenu menu = new PopupMenu(anchorView.getContext(), anchorView, Gravity.END);
    menu.getMenuInflater().inflate(R.menu.menu_feed_card_header, menu.getMenu());
    MenuItem editCardLangItem = menu.getMenu().findItem(R.id.menu_feed_card_edit_card_languages);
    editCardLangItem.setVisible(getCard().type().contentType().isPerLanguage());
    menu.setOnMenuItemClickListener(new OverflowMenuClickListener());
    menu.show();
}
Also used : MenuItem(android.view.MenuItem) PopupMenu(android.support.v7.widget.PopupMenu)

Example 97 with PopupMenu

use of android.support.v7.widget.PopupMenu in project apps-android-wikipedia by wikimedia.

the class ReadingListBookmarkMenu method showMenu.

private void showMenu() {
    if (!existsInAnyList && isListsContainingPageEmpty()) {
        return;
    }
    Context context = anchorView.getContext();
    PopupMenu menu = new PopupMenu(context, anchorView);
    menu.getMenuInflater().inflate(menuRes, menu.getMenu());
    menu.setOnMenuItemClickListener(new PageSaveMenuClickListener());
    if (listsContainingPage.size() == 1) {
        MenuItem removeItem = menu.getMenu().findItem(R.id.menu_remove_from_lists);
        removeItem.setTitle(context.getString(R.string.reading_list_remove_from_list, listsContainingPage.get(0).title()));
    }
    if (existsInAnyList) {
        menu.setGravity(Gravity.END);
        MenuItem addToOtherItem = menu.getMenu().findItem(R.id.menu_add_to_other_list);
        addToOtherItem.setVisible(listsContainingPage.size() > 0);
        addToOtherItem.setEnabled(listsContainingPage.size() > 0);
        MenuItem removeItem = menu.getMenu().findItem(R.id.menu_remove_from_lists);
        removeItem.setVisible(listsContainingPage.size() > 0);
        removeItem.setEnabled(listsContainingPage.size() > 0);
        MenuItem saveItem = menu.getMenu().findItem(R.id.menu_feed_card_item_save);
        saveItem.setVisible(listsContainingPage.size() == 0);
        saveItem.setEnabled(listsContainingPage.size() == 0);
    }
    menu.show();
}
Also used : Context(android.content.Context) MenuItem(android.view.MenuItem) PopupMenu(android.support.v7.widget.PopupMenu)

Example 98 with PopupMenu

use of android.support.v7.widget.PopupMenu in project ZhihuDailyPurify by izzyleung.

the class NewsAdapter method onCreateViewHolder.

@Override
public CardViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final Context context = parent.getContext();
    View itemView = LayoutInflater.from(context).inflate(R.layout.news_list_item, parent, false);
    return new CardViewHolder(itemView, new CardViewHolder.ClickResponseListener() {

        @Override
        public void onWholeClick(int position) {
            browse(context, position);
        }

        @Override
        public void onOverflowClick(View v, int position) {
            PopupMenu popup = new PopupMenu(context, v);
            MenuInflater inflater = popup.getMenuInflater();
            inflater.inflate(R.menu.contextual_news_list, popup.getMenu());
            popup.setOnMenuItemClickListener(item -> {
                switch(item.getItemId()) {
                    case R.id.action_share_url:
                        share(context, position);
                        break;
                }
                return true;
            });
            popup.show();
        }
    });
}
Also used : Context(android.content.Context) Context(android.content.Context) Stream(com.annimon.stream.Stream) DailyNews(io.github.izzyleung.zhihudailypurify.bean.DailyNews) Uri(android.net.Uri) ImageView(android.widget.ImageView) Intent(android.content.Intent) MenuInflater(android.view.MenuInflater) PopupMenu(android.widget.PopupMenu) Toast(android.widget.Toast) Question(io.github.izzyleung.zhihudailypurify.bean.Question) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) View(android.view.View) LinkedList(java.util.LinkedList) Check(io.github.izzyleung.zhihudailypurify.support.Check) Constants(io.github.izzyleung.zhihudailypurify.support.Constants) DialogInterface(android.content.DialogInterface) ZhihuDailyPurifyApplication(io.github.izzyleung.zhihudailypurify.ZhihuDailyPurifyApplication) LayoutInflater(android.view.LayoutInflater) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) ImageLoader(com.nostra13.universalimageloader.core.ImageLoader) R(io.github.izzyleung.zhihudailypurify.R) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) ViewGroup(android.view.ViewGroup) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) Bitmap(android.graphics.Bitmap) Collections(java.util.Collections) MenuInflater(android.view.MenuInflater) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) PopupMenu(android.widget.PopupMenu)

Example 99 with PopupMenu

use of android.support.v7.widget.PopupMenu in project ListenerMusicPlayer by hefuyicoder.

the class FolderAdapter method setOnPopupMenuListener.

private void setOnPopupMenuListener(final ItemHolder itemHolder, final int position) {
    itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final PopupMenu menu = new PopupMenu(mContext, v);
            int adapterPosition = itemHolder.getAdapterPosition();
            final FolderInfo folderInfo = arraylist.get(adapterPosition);
            menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.popup_folder_addto_queue:
                            getSongListIdByFolder(folderInfo.folderPath).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                @Override
                                public void call(long[] ids) {
                                    MusicPlayer.addToQueue(mContext, ids, -1, ListenerUtil.IdType.Folder);
                                }
                            });
                            break;
                        case R.id.popup_folder_addto_playlist:
                            getSongListIdByFolder(folderInfo.folderPath).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                @Override
                                public void call(long[] ids) {
                                    ListenerUtil.showAddPlaylistDialog(mContext, ids);
                                }
                            });
                            break;
                        case R.id.popup_folder_delete:
                            new MaterialDialog.Builder(mContext).title(mContext.getResources().getString(R.string.delete_folder)).content("删除文件夹下" + folderInfo.songCount + "首歌曲?").positiveText(R.string.delete).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {

                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    getSongListIdByFolder(folderInfo.folderPath).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                        @Override
                                        public void call(long[] ids) {
                                            ListenerUtil.deleteTracks(mContext, ids);
                                            RxBus.getInstance().post(new MediaUpdateEvent());
                                        }
                                    });
                                }
                            }).onNegative(new MaterialDialog.SingleButtonCallback() {

                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    dialog.dismiss();
                                }
                            }).show();
                            break;
                    }
                    return false;
                }
            });
            menu.inflate(R.menu.popup_folder);
            menu.show();
        }
    });
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Action1(rx.functions.Action1) MediaUpdateEvent(io.hefuyi.listener.event.MediaUpdateEvent) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) FastScrollRecyclerView(io.hefuyi.listener.widget.fastscroller.FastScrollRecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) FolderInfo(io.hefuyi.listener.mvp.model.FolderInfo) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) PopupMenu(android.widget.PopupMenu)

Example 100 with PopupMenu

use of android.support.v7.widget.PopupMenu in project ListenerMusicPlayer by hefuyicoder.

the class PlaylistAdapter method setOnPopupMenuListener.

private void setOnPopupMenuListener(final ItemHolder itemHolder, final int position) {
    itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final PopupMenu menu = new PopupMenu(mContext, v);
            menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    final Playlist playlist = arraylist.get(itemHolder.getAdapterPosition());
                    switch(item.getItemId()) {
                        case R.id.popup_playlist_rename:
                            new MaterialDialog.Builder(mContext).title(R.string.rename_playlist).positiveText("确定").negativeText(R.string.cancel).input(null, playlist.name, false, new MaterialDialog.InputCallback() {

                                @Override
                                public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
                                    MusicPlayer.renamePlaylist(mContext, playlist.id, input.toString());
                                    itemHolder.title.setText(input.toString());
                                    Toast.makeText(mContext, R.string.rename_playlist_success, Toast.LENGTH_SHORT).show();
                                }
                            }).show();
                            break;
                        case R.id.popup_playlist_addto_playlist:
                            getSongListIdByPlaylist(playlist.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                @Override
                                public void call(long[] ids) {
                                    ListenerUtil.showAddPlaylistDialog(mFragment.getActivity(), ids);
                                }
                            });
                            break;
                        case R.id.popup_playlist_addto_queue:
                            getSongListIdByPlaylist(playlist.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                @Override
                                public void call(long[] ids) {
                                    MusicPlayer.addToQueue(mContext, ids, -1, ListenerUtil.IdType.Playlist);
                                }
                            });
                            break;
                        case R.id.popup_playlist_delete:
                            new MaterialDialog.Builder(mContext).title(R.string.delete_playlist).positiveText(R.string.delete).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {

                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    PlaylistLoader.deletePlaylists(mContext, playlist.id);
                                    arraylist.remove(itemHolder.getAdapterPosition());
                                    notifyItemRemoved(itemHolder.getAdapterPosition());
                                    Toast.makeText(mContext, R.string.delete_playlist_success, Toast.LENGTH_SHORT).show();
                                }
                            }).onNegative(new MaterialDialog.SingleButtonCallback() {

                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    dialog.dismiss();
                                }
                            }).show();
                            break;
                    }
                    return false;
                }
            });
            menu.inflate(R.menu.popup_playlist);
            menu.show();
        }
    });
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) FastScrollRecyclerView(io.hefuyi.listener.widget.fastscroller.FastScrollRecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Playlist(io.hefuyi.listener.mvp.model.Playlist) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) PopupMenu(android.widget.PopupMenu)

Aggregations

PopupMenu (android.support.v7.widget.PopupMenu)142 MenuItem (android.view.MenuItem)116 View (android.view.View)86 TextView (android.widget.TextView)63 RecyclerView (android.support.v7.widget.RecyclerView)54 ImageView (android.widget.ImageView)40 Intent (android.content.Intent)32 PopupMenu (android.widget.PopupMenu)31 List (java.util.List)27 ArrayList (java.util.ArrayList)26 MenuInflater (android.view.MenuInflater)23 Menu (android.view.Menu)22 Bundle (android.os.Bundle)20 LayoutInflater (android.view.LayoutInflater)20 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)20 Context (android.content.Context)18 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)18 AdapterView (android.widget.AdapterView)17 DialogInterface (android.content.DialogInterface)16 ViewGroup (android.view.ViewGroup)15