diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-08-17 12:19:37 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-08-17 12:19:37 -0700 |
commit | b9959f41efe45548757d0a7f1b1c9eb4ec9f9e92 (patch) | |
tree | 1007219259b02ef68b59491b146dbbdc9f0d4230 /src | |
parent | 92f924b46d2ecd05669e27a93f5ced3d00f79cf7 (diff) | |
download | dsub-b9959f41efe45548757d0a7f1b1c9eb4ec9f9e92.tar.gz dsub-b9959f41efe45548757d0a7f1b1c9eb4ec9f9e92.tar.bz2 dsub-b9959f41efe45548757d0a7f1b1c9eb4ec9f9e92.zip |
Update playlist caches for stars as well
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/service/CachedMusicService.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java index 027f6694..e97ffe24 100644 --- a/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -386,6 +386,11 @@ public class CachedMusicService implements MusicService { private void updateStarredList(Context context, List<Entry> list, final boolean starred, final boolean isTagBrowsing) { for(final Entry entry: list) { + // Don't waste time when status is the same + if(entry.isStarred() == starred) { + continue; + } + String cacheName, parent = null; boolean isArtist = false; if(isTagBrowsing) { @@ -595,6 +600,30 @@ public class CachedMusicService implements MusicService { } }.execute(); } + + // Update playlist caches if there is at least one song to be starred + if(ids != null && ids.size() > 0) { + List<Playlist> playlists = FileUtil.deserialize(context, getCacheName(context, "playlist"), ArrayList.class); + for(Playlist playlist: playlists) { + new MusicDirectoryUpdater(context, "playlist", playlist.getId()) { + @Override + public boolean checkResult(Entry check) { + for (String id : checkIds) { + if (id.equals(check.getId())) { + return true; + } + } + + return false; + } + + @Override + public void updateResult(List<Entry> objects, Entry result) { + result.setStarred(starred); + } + }.execute(); + } + } } @Override |