aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-03-31 20:32:21 -0700
committerScott Jackson <daneren2005@gmail.com>2014-03-31 20:32:21 -0700
commitd66a640e877612589ef55be0d563b1abd0b5852c (patch)
tree159807b332e1cb6e8990d0e683810c5ff5b1779c
parent512ccb7f735249ac55af971d186cad88f9d116df (diff)
downloaddsub-d66a640e877612589ef55be0d563b1abd0b5852c.tar.gz
dsub-d66a640e877612589ef55be0d563b1abd0b5852c.tar.bz2
dsub-d66a640e877612589ef55be0d563b1abd0b5852c.zip
#318 Try to do lookup for correct albumart on multi disc albums
-rw-r--r--src/github/daneren2005/dsub/util/FileUtil.java32
-rw-r--r--src/github/daneren2005/dsub/util/ImageLoader.java7
2 files changed, 27 insertions, 12 deletions
diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java
index a1983fde..3b45115b 100644
--- a/src/github/daneren2005/dsub/util/FileUtil.java
+++ b/src/github/daneren2005/dsub/util/FileUtil.java
@@ -235,18 +235,10 @@ public class FileUtil {
File f = new File(fileSystemSafeDir(entry.getPath()));
dir = new File(getMusicDirectory(context).getPath() + "/" + (entry.isDirectory() ? f.getPath() : f.getParent()));
} else {
- // Do a special lookup since 4.7+ doesn't match artist/album to entry.getPath
- String s = Util.getRestUrl(context, null, false) + entry.getId();
- String cacheName = (Util.isTagBrowsing(context) ? "album-" : "directory-") + s.hashCode() + ".ser";
- MusicDirectory entryDir = FileUtil.deserialize(context, cacheName, MusicDirectory.class);
-
- if(entryDir != null) {
- List<MusicDirectory.Entry> songs = entryDir.getChildren(false, true);
- if(songs.size() > 0) {
- MusicDirectory.Entry firstSong = songs.get(0);
- File songFile = FileUtil.getSongFile(context, firstSong);
- dir = songFile.getParentFile();
- }
+ MusicDirectory.Entry firstSong = lookupChild(context, entry, false);
+ if(firstSong != null) {
+ File songFile = FileUtil.getSongFile(context, firstSong);
+ dir = songFile.getParentFile();
}
if(dir == null) {
@@ -260,6 +252,22 @@ public class FileUtil {
}
return dir;
}
+
+ public static MusicDirectory.Entry lookupChild(Context context, MusicDirectory.Entry entry, boolean allowDir) {
+ // Do a special lookup since 4.7+ doesn't match artist/album to entry.getPath
+ String s = Util.getRestUrl(context, null, false) + entry.getId();
+ String cacheName = (Util.isTagBrowsing(context) ? "album-" : "directory-") + s.hashCode() + ".ser";
+ MusicDirectory entryDir = FileUtil.deserialize(context, cacheName, MusicDirectory.class);
+
+ if(entryDir != null) {
+ List<MusicDirectory.Entry> songs = entryDir.getChildren(allowDir, true);
+ if(songs.size() > 0) {
+ return songs.get(0);
+ }
+ }
+
+ return null;
+ }
public static String getPodcastPath(Context context, PodcastEpisode episode) {
return fileSystemSafe(episode.getArtist()) + "/" + fileSystemSafe(episode.getTitle());
diff --git a/src/github/daneren2005/dsub/util/ImageLoader.java b/src/github/daneren2005/dsub/util/ImageLoader.java
index 970e1b0e..37727891 100644
--- a/src/github/daneren2005/dsub/util/ImageLoader.java
+++ b/src/github/daneren2005/dsub/util/ImageLoader.java
@@ -121,6 +121,13 @@ public class ImageLoader {
createLargeUnknownImage(view.getContext());
}
+ if(entry != null && entry.getCoverArt() == null && entry.isDirectory()) {
+ // Try to lookup child cover art
+ MusicDirectory.Entry firstChild = FileUtil.lookupChild(context, entry, true);
+ if(firstChild != null) {
+ entry.setCoverArt(firstChild.getCoverArt());
+ }
+ }
if (entry == null || entry.getCoverArt() == null) {
setUnknownImage(view, large);
return;