@Override
  public boolean onMenuItemClick(MenuItem item) {
    final Song nowPlaying = PlayerController.getNowPlaying();
    if (nowPlaying == null) {
      return false;
    }

    switch (item.getItemId()) {
      case 0: // Go to artist
        Artist artist = Library.findArtistById(nowPlaying.getArtistId());
        Navigate.to(getContext(), ArtistActivity.class, ArtistActivity.ARTIST_EXTRA, artist);
        return true;
      case 1: // Go to album
        Album album = Library.findAlbumById(nowPlaying.getAlbumId());

        Navigate.to(getContext(), AlbumActivity.class, AlbumActivity.ALBUM_EXTRA, album);
        return true;
      case 2: // Add to playlist
        PlaylistDialog.AddToNormal.alert(
            getView(),
            nowPlaying,
            getString(R.string.header_add_song_name_to_playlist, nowPlaying.getSongName()));
        return true;
    }
    return false;
  }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.instanceMore:
       final PopupMenu menu = new PopupMenu(context, v, Gravity.END);
       String[] options = context.getResources().getStringArray(R.array.queue_options_playlist);
       for (int i = 0; i < options.length; i++) {
         menu.getMenu().add(Menu.NONE, i, i, options[i]);
       }
       menu.setOnMenuItemClickListener(
           new PopupMenu.OnMenuItemClickListener() {
             @Override
             public boolean onMenuItemClick(MenuItem menuItem) {
               switch (menuItem.getItemId()) {
                 case 0: // Queue this playlist next
                   PlayerController.queueNext(Library.getPlaylistEntries(context, reference));
                   return true;
                 case 1: // Queue this playlist last
                   PlayerController.queueLast(Library.getPlaylistEntries(context, reference));
                   return true;
                 case 2: // Delete this playlist
                   Library.removePlaylist(itemView, reference);
                   return true;
               }
               return false;
             }
           });
       menu.show();
       break;
     default:
       Navigate.to(context, PlaylistActivity.class, PlaylistActivity.PLAYLIST_EXTRA, reference);
       break;
   }
 }
Example #3
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.instanceMore:
       final PopupMenu menu = new PopupMenu(context, v, Gravity.END);
       String[] options = context.getResources().getStringArray(R.array.queue_options_genre);
       for (int i = 0; i < options.length; i++) {
         menu.getMenu().add(Menu.NONE, i, i, options[i]);
       }
       menu.setOnMenuItemClickListener(this);
       menu.show();
       break;
     default:
       Navigate.to(context, GenreActivity.class, GenreActivity.GENRE_EXTRA, reference);
       break;
   }
 }