diff options
author | daneren2005 <daneren2005@gmail.com> | 2014-04-25 13:43:01 -0700 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2014-04-25 13:43:01 -0700 |
commit | 80f73f1e8e265527ae0a7beb74766d02ac2da49b (patch) | |
tree | e48ef26ec09f5cb28e7facaa37d9c09f34d78078 | |
parent | cb9befec2a3c57c48b87b0f01cc086dd6bf83730 (diff) | |
download | dsub-80f73f1e8e265527ae0a7beb74766d02ac2da49b.tar.gz dsub-80f73f1e8e265527ae0a7beb74766d02ac2da49b.tar.bz2 dsub-80f73f1e8e265527ae0a7beb74766d02ac2da49b.zip |
Ratings API appears to be unused at any scope
-rw-r--r-- | src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java b/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java deleted file mode 100644 index 532aec5b..00000000 --- a/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java +++ /dev/null @@ -1,82 +0,0 @@ -package github.daneren2005.dsub.util.compat; - -import github.daneren2005.dsub.domain.MusicDirectory; -import github.daneren2005.dsub.util.ImageLoader; -import android.annotation.TargetApi; -import android.app.PendingIntent; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.media.AudioManager; -import android.media.MediaMetadataEditor; -import android.media.MediaMetadataRetriever; -import android.media.Rating; -import android.media.RemoteControlClient; -import android.os.AsyncTask; -import android.util.Log; - -import github.daneren2005.dsub.activity.SubsonicActivity; -import github.daneren2005.dsub.service.DownloadService; -import github.daneren2005.dsub.service.MusicService; -import github.daneren2005.dsub.service.MusicServiceFactory; -import github.daneren2005.dsub.util.SilentBackgroundTask; -import github.daneren2005.dsub.util.Util; -import java.io.File; -import java.util.Arrays; - -@TargetApi(19) -public class RemoteControlClientKK extends RemoteControlClientJB { - private static String TAG = RemoteControlClientKK.class.getSimpleName(); - protected MusicDirectory.Entry currentSong; - - @Override - public void register(final Context context, final ComponentName mediaButtonReceiverComponent) { - super.register(context, mediaButtonReceiverComponent); - - mRemoteControl.setMetadataUpdateListener(new RemoteControlClient.OnMetadataUpdateListener() { - @Override - public void onMetadataUpdate(int key, Object newValue) { - if(key == MediaMetadataEditor.RATING_KEY_BY_USER) { - Rating rating = (Rating) newValue; - setStarred(currentSong, rating.hasHeart()); - } - } - }); - } - - @Override - protected void updateMetadata(final MusicDirectory.Entry currentSong, final RemoteControlClient.MetadataEditor editor) { - super.updateMetadata(currentSong, editor); - editor.putObject(MediaMetadataEditor.RATING_KEY_BY_USER, Rating.newHeartRating(currentSong.isStarred())); - editor.addEditableKey(MediaMetadataEditor.RATING_KEY_BY_USER); - this.currentSong = currentSong; - } - - @Override - protected int getTransportFlags() { - return super.getTransportFlags() | RemoteControlClient.FLAG_KEY_MEDIA_RATING; - } - - private void setStarred(final MusicDirectory.Entry entry, final boolean starred) { - entry.setStarred(starred); - - new AsyncTask<Void, Void, Void>() { - @Override - protected Void doInBackground(Void... params) { - try { - MusicService musicService = MusicServiceFactory.getMusicService(downloadService); - musicService.setStarred(Arrays.asList(entry.getId()), null, null, starred, downloadService, null); - - // Make sure to clear parent cache - String s = Util.getRestUrl(downloadService, null) + entry.getParent(); - String parentCache = "directory-" + s.hashCode() + ".ser"; - File file = new File(downloadService.getCacheDir(), parentCache); - file.delete(); - } catch(Exception e) { - Log.w(TAG, "Failed to set star for " + entry.getTitle()); - } - return null; - } - }.execute(); - } -} |