Exemplo n.º 1
0
  /** {@inheritDoc} */
  @Override
  public void onCreateContextMenu(
      final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    // Get the position of the selected item
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    // Creat a new model
    mArtist = mAdapter.getItem(info.position);
    // Create a list of the artist's songs
    mArtistList = MusicUtils.getSongListForArtist(getActivity(), mArtist.mArtistId);

    // Play the artist
    menu.add(
        GROUP_ID,
        FragmentMenuItems.PLAY_SELECTION,
        Menu.NONE,
        getString(R.string.context_menu_play_selection));

    // Add the artist to the queue
    menu.add(GROUP_ID, FragmentMenuItems.ADD_TO_QUEUE, Menu.NONE, getString(R.string.add_to_queue));

    // Add the artist to a playlist
    final SubMenu subMenu =
        menu.addSubMenu(
            GROUP_ID, FragmentMenuItems.ADD_TO_PLAYLIST, Menu.NONE, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(getActivity(), GROUP_ID, subMenu, false);

    // Delete the artist
    menu.add(
        GROUP_ID, FragmentMenuItems.DELETE, Menu.NONE, getString(R.string.context_menu_delete));
  }
Exemplo n.º 2
0
 /**
  * @return The position of an item in the list or grid based on the name of the currently playing
  *     artist.
  */
 private int getItemPositionByArtist() {
   final long artistId = MusicUtils.getCurrentArtistId();
   if (mAdapter == null) {
     return 0;
   }
   for (int i = 0; i < mAdapter.getCount(); i++) {
     if (mAdapter.getItem(i).mArtistId == artistId) {
       return i;
     }
   }
   return 0;
 }
Exemplo n.º 3
0
 /** {@inheritDoc} */
 @Override
 public void onItemClick(
     final AdapterView<?> parent, final View view, final int position, final long id) {
   mArtist = mAdapter.getItem(position);
   NavUtils.openArtistProfile(getActivity(), mArtist.mArtistName);
 }