aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-09-10 16:27:46 -0700
committerScott Jackson <daneren2005@gmail.com>2014-09-10 16:27:46 -0700
commite17b447ebb300da3be616ad302e4b078db55327a (patch)
tree0fa9db6909985a54850a8ee0e91d873ef7e50f6d /src/github
parentedea08b5a14d68f9fa4f4e1c24982e58c57651cf (diff)
downloaddsub-e17b447ebb300da3be616ad302e4b078db55327a.tar.gz
dsub-e17b447ebb300da3be616ad302e4b078db55327a.tar.bz2
dsub-e17b447ebb300da3be616ad302e4b078db55327a.zip
If recently added album has no parent, then it is a root level album and needs to be added as an artist
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/service/CachedMusicService.java35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java
index 867c6d49..7253788a 100644
--- a/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -387,7 +387,7 @@ public class CachedMusicService implements MusicService {
public void updateResult(List<Entry> objects, Entry result) {
// Only add if it doesn't already exist in it!
if(!objects.contains(album)) {
- objects.add(result);
+ objects.add(album);
changed = true;
}
}
@@ -403,6 +403,39 @@ public class CachedMusicService implements MusicService {
}
}
}.execute();
+ } else {
+ // If parent is null, then this is a root level album
+ Artist artist = new Artist();
+ artist.setId(album.getId());
+ artist.setName(album.getTitle();
+
+ new IndexesUpdater(context, isTagBrowsing ? "artists" : "indexes") {
+ private boolean changed = false;
+
+ @Override
+ public boolean checkResult(Artist check) {
+ return true;
+ }
+
+ @Override
+ public void updateResult(List<Artist> objects, Artist result) {
+ if(!objects.contains(artist)) {
+ objects.add(artist);
+ changed = true;
+ }
+ }
+
+ @Override
+ public void save(ArrayList<Artist> objects) {
+ if(changed) {
+ indexes.setArtists(objects);
+ // Reapply sort after addition
+ indexes.sortChildren(context);
+ FileUtil.serialize(context, indexes, cacheName);
+ cachedIndexes.set(indexes);
+ }
+ }
+ }.execute();
}
}
}