Search in sources :

Example 11 with AlbumArtist

use of com.simplecity.amp_library.model.AlbumArtist in project Shuttle by timusus.

the class SuggestedFragment method onOverflowClick.

@Override
public void onOverflowClick(View v, int position, Object item) {
    if (item instanceof AlbumArtist) {
        PopupMenu menu = new PopupMenu(SuggestedFragment.this.getActivity(), v);
        MenuUtils.addAlbumArtistMenuOptions(getActivity(), menu);
        MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, (AlbumArtist) item);
        menu.show();
    } else if (item instanceof Album) {
        PopupMenu menu = new PopupMenu(SuggestedFragment.this.getActivity(), v);
        MenuUtils.addAlbumMenuOptions(getActivity(), menu);
        MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, (Album) item);
        menu.show();
    } else if (item instanceof Song) {
        PopupMenu menu = new PopupMenu(SuggestedFragment.this.getActivity(), v);
        MenuUtils.addSongMenuOptions(getActivity(), menu);
        MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, (Song) item, menuItem -> {
            switch(menuItem.getItemId()) {
                case BLACKLIST:
                    {
                        BlacklistHelper.addToBlacklist(((Song) item));
                        suggestedAdapter.removeItem(position);
                        return true;
                    }
            }
            return false;
        });
        menu.show();
    }
}
Also used : Song(com.simplecity.amp_library.model.Song) AppCompatActivity(android.support.v7.app.AppCompatActivity) Album(com.simplecity.amp_library.model.Album) AlbumArtist(com.simplecity.amp_library.model.AlbumArtist) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

AlbumArtist (com.simplecity.amp_library.model.AlbumArtist)11 Album (com.simplecity.amp_library.model.Album)10 Song (com.simplecity.amp_library.model.Song)8 Serializable (java.io.Serializable)7 ArrayList (java.util.ArrayList)7 Intent (android.content.Intent)6 PopupMenu (android.support.v7.widget.PopupMenu)6 Playlist (com.simplecity.amp_library.model.Playlist)6 List (java.util.List)6 Context (android.content.Context)5 SubMenu (android.view.SubMenu)5 DialogUtils (com.simplecity.amp_library.utils.DialogUtils)5 BroadcastReceiver (android.content.BroadcastReceiver)4 Bundle (android.os.Bundle)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 RecyclerView (android.support.v7.widget.RecyclerView)4 Menu (android.view.Menu)4 MenuItem (android.view.MenuItem)4 View (android.view.View)4 AppCompatActivity (android.support.v7.app.AppCompatActivity)3