Exemplo n.º 1
0
 @Override
 public boolean onContextItemSelected(final android.view.MenuItem item) {
   if (item.getGroupId() == GROUP_ID) {
     switch (item.getItemId()) {
       case FragmentMenuItems.PLAY_SELECTION:
         MusicUtils.playAll(getActivity(), new long[] {mSelectedId}, 0, false);
         return true;
       case FragmentMenuItems.PLAY_NEXT:
         MusicUtils.playNext(new long[] {mSelectedId});
         return true;
       case FragmentMenuItems.EDIT_TAGS:
         ApolloUtils.showTagsEditor(getActivity(), mSong);
         return true;
       case FragmentMenuItems.ADD_TO_QUEUE:
         MusicUtils.addToQueue(getActivity(), new long[] {mSelectedId});
         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 playlistId = item.getIntent().getLongExtra("playlist", 0);
         MusicUtils.addToPlaylist(getActivity(), new long[] {mSelectedId}, playlistId);
         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");
         SystemClock.sleep(10);
         mAdapter.notifyDataSetChanged();
         getLoaderManager().restartLoader(LOADER, null, this);
         return true;
       case FragmentMenuItems.REMOVE_FROM_PLAYLIST:
         mAdapter.remove(mSong);
         mAdapter.notifyDataSetChanged();
         MusicUtils.removeFromPlaylist(getActivity(), mSong.mSongId, mPlaylistId);
         getLoaderManager().restartLoader(LOADER, null, this);
         return true;
       default:
         break;
     }
   }
   return super.onContextItemSelected(item);
 }
Exemplo n.º 2
0
 @Override
 public boolean onContextItemSelected(final android.view.MenuItem item) {
   if (item.getGroupId() == GROUP_ID) {
     switch (item.getItemId()) {
       case FragmentMenuItems.PLAY_SELECTION:
         MusicUtils.playAll(getActivity(), new long[] {mSelectedId}, 0, false);
         return true;
       case FragmentMenuItems.ADD_TO_QUEUE:
         MusicUtils.addToQueue(getActivity(), new long[] {mSelectedId});
         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:
         mShouldRefresh = true;
         DeleteDialog.newInstance(mSong.mSongName, new long[] {mSelectedId}, null)
             .show(getFragmentManager(), "DeleteDialog");
         return true;
       default:
         break;
     }
   }
   return super.onContextItemSelected(item);
 }