aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-08-29 15:20:26 -0700
committerScott Jackson <daneren2005@gmail.com>2014-08-29 15:20:26 -0700
commitf7f5b5be1bbde0f6e4dfe95ce1f0e23950484450 (patch)
treeb06436b378f2a8a2b2fbad47a27d6018e0d63da6
parentc334900517c2b015938718e9ac85f8762f74ca9f (diff)
downloaddsub-f7f5b5be1bbde0f6e4dfe95ce1f0e23950484450.tar.gz
dsub-f7f5b5be1bbde0f6e4dfe95ce1f0e23950484450.tar.bz2
dsub-f7f5b5be1bbde0f6e4dfe95ce1f0e23950484450.zip
Update rating cache immediately
-rw-r--r--src/github/daneren2005/dsub/service/CachedMusicService.java52
1 files changed, 50 insertions, 2 deletions
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java
index 90e5539c..01e50e95 100644
--- a/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -792,8 +792,15 @@ public class CachedMusicService implements MusicService {
}
@Override
- public void setRating(String id, int rating, Context context, ProgressListener progressListener) throws Exception {
- musicService.setRating(id, rating, context, progressListener);
+ public void setRating(final String id, String parent, final int rating, Context context, ProgressListener progressListener) throws Exception {
+ musicService.setRating(id, parent, rating, context, progressListener);
+
+ new GenericSongUpdater(context, parent, id) {
+ @Override
+ public void updateResult(Entry result) {
+ result.setRating(rating);
+ }
+ }.execute();
}
@Override
@@ -1222,6 +1229,47 @@ public class CachedMusicService implements MusicService {
}
}
}
+ private abstract class GenericSongUpdater {
+ Context context;
+ String id;
+ String parent;
+
+ public GenericSongUpdater(Context context, String id, String parent) {
+ this.context = context;
+ this.id = id;
+ this.parent = parent;
+ }
+
+ public boolean checkResult(Entry check) {
+ return id.equals(check.getId());
+ }
+ public abstract void updateResult(Entry result);
+
+ public void execute() {
+ new MusicDirectoryUpdater(context, "directory", parent) {
+ @Override
+ public boolean checkResult(Entry check) {
+ return GenericSongUpdater.this.checkResult(check);
+ }
+
+ @Override void updateResult(List<Entry> objects, Entry result) {
+ GenericSongUpdater.this.updateResult(result);
+ }
+ }.execute();
+
+ new PlaylistDirectoryUpdater(context) {
+ @Override
+ public boolean checkResult(Entry check) {
+ return GenericSongUpdater.this.checkResult(check);
+ }
+
+ @Override
+ public void updateResult(Entry result) {
+ GenericSongUpdater.this.updateResult(result);
+ }
+ }.execute();
+ }
+ }
private abstract class IndexesUpdater extends SerializeUpdater<Artist> {
Indexes indexes;