コード例 #1
0
 /** {@inheritDoc} */
 @Override
 public boolean onContextItemSelected(final android.view.MenuItem item) {
   if (item.getGroupId() == GROUP_ID) {
     switch (item.getItemId()) {
       case FragmentMenuItems.PLAY_NEXT:
         NowPlayingCursor queue = (NowPlayingCursor) QueueLoader.makeQueueCursor(getActivity());
         queue.removeItem(mSelectedPosition);
         queue.close();
         queue = null;
         MusicUtils.playNext(new long[] {mSelectedId});
         refreshQueue();
         return true;
       case FragmentMenuItems.REMOVE_FROM_QUEUE:
         MusicUtils.removeTrack(mSelectedId);
         refreshQueue();
         return true;
       case FragmentMenuItems.ADD_TO_FAVORITES:
         FavoritesStore.getInstance(getActivity())
             .addSongId(mSelectedId, mSongName, mAlbumName, mArtistName);
         return true;
       case FragmentMenuItems.NEW_PLAYLIST:
         CreateNewPlaylist.getInstance(new long[] {mSelectedId})
             .show(getFragmentManager(), "CreatePlaylist");
         return true;
       case FragmentMenuItems.PLAYLIST_SELECTED:
         final long mPlaylistId = item.getIntent().getLongExtra("playlist", 0);
         MusicUtils.addToPlaylist(getActivity(), new long[] {mSelectedId}, mPlaylistId);
         return true;
       case FragmentMenuItems.MORE_BY_ARTIST:
         NavUtils.openArtistProfile(getActivity(), mArtistName);
         return true;
       case FragmentMenuItems.USE_AS_RINGTONE:
         MusicUtils.setRingtone(getActivity(), mSelectedId);
         return true;
       case FragmentMenuItems.DELETE:
         DeleteDialog.newInstance(mSong.mSongName, new long[] {mSelectedId}, null)
             .show(getFragmentManager(), "DeleteDialog");
         return true;
       default:
         break;
     }
   }
   return super.onContextItemSelected(item);
 }
コード例 #2
0
 /** {@inheritDoc} */
 @Override
 public boolean onOptionsItemSelected(final MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_save_queue:
       NowPlayingCursor queue = (NowPlayingCursor) QueueLoader.makeQueueCursor(getActivity());
       CreateNewPlaylist.getInstance(MusicUtils.getSongListForCursor(queue))
           .show(getFragmentManager(), "CreatePlaylist");
       queue.close();
       queue = null;
       return true;
     case R.id.menu_clear_queue:
       MusicUtils.clearQueue();
       NavUtils.goHome(getActivity());
       return true;
     default:
       break;
   }
   return super.onOptionsItemSelected(item);
 }