Search in sources :

Example 11 with PopupMenu

use of android.support.v7.widget.PopupMenu in project Shuttle by timusus.

the class NavigationDrawerFragment method onOverflowButtonClick.

@Override
public void onOverflowButtonClick(View v, final Playlist playlist) {
    PopupMenu popupMenu = new PopupMenu(getActivity(), v);
    MenuUtils.addPlaylistMenuOptions(popupMenu, playlist);
    MenuUtils.addClickHandler(getActivity(), popupMenu, playlist, null, null);
    popupMenu.show();
}
Also used : PopupMenu(android.support.v7.widget.PopupMenu)

Example 12 with PopupMenu

use of android.support.v7.widget.PopupMenu in project Shuttle by timusus.

the class AlbumArtistFragment method onOverflowClick.

@Override
public void onOverflowClick(View v, int position, AlbumArtist albumArtist) {
    PopupMenu menu = new PopupMenu(AlbumArtistFragment.this.getActivity(), v);
    MenuUtils.addAlbumArtistMenuOptions(getActivity(), menu);
    MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, albumArtist);
    menu.show();
}
Also used : PopupMenu(android.support.v7.widget.PopupMenu)

Example 13 with PopupMenu

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

the class AlbumAdapter method setOnPopupMenuListener.

private void setOnPopupMenuListener(final AlbumAdapter.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 Album album = arraylist.get(adapterPosition);
            menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.popup_album_addto_queue:
                            getSongListIdByAlbum(arraylist.get(position).id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                @Override
                                public void call(long[] ids) {
                                    MusicPlayer.addToQueue(mContext, ids, -1, ListenerUtil.IdType.NA);
                                }
                            });
                            break;
                        case R.id.popup_album_addto_playlist:
                            getSongListIdByAlbum(arraylist.get(position).id).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_album_goto_artist:
                            NavigationUtil.goToArtist(mContext, arraylist.get(position).artistId, arraylist.get(position).artistName);
                            break;
                        case R.id.popup_artist_delete:
                            switch(action) {
                                case Constants.NAVIGATE_PLAYLIST_FAVOURATE:
                                    getSongListIdByAlbum(album.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                        @Override
                                        public void call(long[] ids) {
                                            ListenerUtil.showDeleteFromFavourate(mContext, ids);
                                        }
                                    });
                                    break;
                                case Constants.NAVIGATE_PLAYLIST_RECENTPLAY:
                                    getSongListIdByAlbum(album.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                        @Override
                                        public void call(long[] ids) {
                                            ListenerUtil.showDeleteFromRecentlyPlay(mContext, ids);
                                        }
                                    });
                                    break;
                                default:
                                    AlbumSongLoader.getSongsForAlbum(mContext, arraylist.get(position).id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<Song>>() {

                                        @Override
                                        public void call(List<Song> songs) {
                                            long[] ids = new long[songs.size()];
                                            int i = 0;
                                            for (Song song : songs) {
                                                ids[i] = song.id;
                                                i++;
                                            }
                                            if (ids.length == 1) {
                                                ListenerUtil.showDeleteDialog(mContext, songs.get(0).title, ids, new MaterialDialog.SingleButtonCallback() {

                                                    @Override
                                                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                                        arraylist.remove(position);
                                                        notifyDataSetChanged();
                                                    }
                                                });
                                            } else {
                                                String songCount = ListenerUtil.makeLabel(mContext, R.plurals.Nsongs, arraylist.get(position).songCount);
                                                ListenerUtil.showDeleteDialog(mContext, songCount, ids, new MaterialDialog.SingleButtonCallback() {

                                                    @Override
                                                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                                        arraylist.remove(position);
                                                        notifyDataSetChanged();
                                                    }
                                                });
                                            }
                                        }
                                    });
                                    break;
                            }
                            break;
                    }
                    return false;
                }
            });
            menu.inflate(R.menu.popup_album);
            menu.show();
        }
    });
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Album(io.hefuyi.listener.mvp.model.Album) 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) Song(io.hefuyi.listener.mvp.model.Song) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) List(java.util.List) PopupMenu(android.widget.PopupMenu)

Example 14 with PopupMenu

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

the class AlbumSongsAdapter 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) {
                    switch(item.getItemId()) {
                        case R.id.popup_song_play_next:
                            long[] ids = new long[1];
                            ids[0] = arraylist.get(position).id;
                            MusicPlayer.playNext(mContext, ids, -1, ListenerUtil.IdType.NA);
                            break;
                        case R.id.popup_song_goto_album:
                            NavigationUtil.goToAlbum(mContext, arraylist.get(position).albumId, arraylist.get(position).title);
                            break;
                        case R.id.popup_song_goto_artist:
                            NavigationUtil.goToArtist(mContext, arraylist.get(position).artistId, arraylist.get(position).artistName);
                            break;
                        case R.id.popup_song_addto_queue:
                            long[] id = new long[1];
                            id[0] = arraylist.get(position).id;
                            MusicPlayer.addToQueue(mContext, id, -1, ListenerUtil.IdType.NA);
                            break;
                        case R.id.popup_song_addto_playlist:
                            ListenerUtil.showAddPlaylistDialog(mContext, new long[] { arraylist.get(itemHolder.getAdapterPosition()).id });
                            break;
                        case R.id.popup_song_delete:
                            long[] deleteIds = { arraylist.get(position).id };
                            ListenerUtil.showDeleteDialog(mContext, arraylist.get(position).title, deleteIds, new MaterialDialog.SingleButtonCallback() {

                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    arraylist.remove(position);
                                    songIDs = getSongIds();
                                    notifyDataSetChanged();
                                }
                            });
                            break;
                    }
                    return false;
                }
            });
            menu.inflate(R.menu.popup_song);
            menu.show();
        }
    });
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DialogAction(com.afollestad.materialdialogs.DialogAction) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) PopupMenu(android.widget.PopupMenu)

Example 15 with PopupMenu

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

the class ArtistSongAdapter method setOnPopupMenuListener.

private void setOnPopupMenuListener(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) {
                    switch(item.getItemId()) {
                        case R.id.popup_song_play_next:
                            long[] ids = new long[1];
                            ids[0] = arraylist.get(position + 1).id;
                            MusicPlayer.playNext(mContext, ids, -1, ListenerUtil.IdType.NA);
                            break;
                        case R.id.popup_song_addto_playlist:
                            ListenerUtil.showAddPlaylistDialog(mContext, new long[] { arraylist.get(position + 1).id });
                            break;
                        case R.id.popup_song_addto_queue:
                            long[] id = new long[1];
                            id[0] = arraylist.get(position + 1).id;
                            MusicPlayer.addToQueue(mContext, id, -1, ListenerUtil.IdType.NA);
                            break;
                        case R.id.popup_song_goto_album:
                            NavigationUtil.goToAlbum(mContext, arraylist.get(position + 1).albumId, arraylist.get(position + 1).title);
                            break;
                        case R.id.popup_song_delete:
                            long[] deleteIds = { arraylist.get(position + 1).id };
                            ListenerUtil.showDeleteDialog(mContext, arraylist.get(position + 1).title, deleteIds, new MaterialDialog.SingleButtonCallback() {

                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    arraylist.remove(position + 1);
                                    songIDs = getSongIds();
                                    notifyDataSetChanged();
                                }
                            });
                            break;
                    }
                    return false;
                }
            });
            menu.inflate(R.menu.popup_song);
            menu.getMenu().findItem(R.id.popup_song_goto_artist).setVisible(false);
            menu.show();
        }
    });
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DialogAction(com.afollestad.materialdialogs.DialogAction) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) 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