diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-12-20 19:01:51 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-12-20 19:01:51 -0800 |
commit | 6577fa6071794b4dc92b05c703a02be13d427048 (patch) | |
tree | bffc9718d2469fcfaa9e1ef9cc5839481946a421 /src | |
parent | 9f11830d6d5e1eb830952e825b6d6a223906e826 (diff) | |
download | dsub-6577fa6071794b4dc92b05c703a02be13d427048.tar.gz dsub-6577fa6071794b4dc92b05c703a02be13d427048.tar.bz2 dsub-6577fa6071794b4dc92b05c703a02be13d427048.zip |
Hacky way to get around albums > 3 deep not being shown as cached
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/view/AlbumView.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/view/AlbumView.java b/src/github/daneren2005/dsub/view/AlbumView.java index 190c5c9f..b29c2ed5 100644 --- a/src/github/daneren2005/dsub/view/AlbumView.java +++ b/src/github/daneren2005/dsub/view/AlbumView.java @@ -31,6 +31,8 @@ import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.ImageLoader; import github.daneren2005.dsub.util.Util; import java.io.File; +import java.util.List; + /** * Used to display albums in a {@code ListView}. * @@ -72,11 +74,31 @@ public class AlbumView extends UpdateView { artistView.setText(album.getArtist()); artistView.setVisibility(album.getArtist() == null ? View.GONE : View.VISIBLE); ((ImageLoader)obj2).loadImage(coverArtView, album, false, true); - file = FileUtil.getAlbumDirectory(context, album); + file = null; } @Override protected void updateBackground() { + if(file == null) { + String s = Util.getRestUrl(context, null) + album.getId(); + String cacheName = "directory-" + s.hashCode() + ".ser"; + MusicDirectory dir = FileUtil.deserialize(context, cacheName, MusicDirectory.class); + + if(dir != null) { + List<MusicDirectory.Entry> songs = dir.getChildren(false, true); + if(songs.size() > 0) { + MusicDirectory.Entry firstSong = songs.get(0); + File songFile = FileUtil.getSongFile(context, firstSong); + file = songFile.getParentFile(); + } + } + + // Backup in case cache is null or can't get dir from it + if(file == null) { + file = FileUtil.getAlbumDirectory(context, album); + } + } + exists = file.exists(); isStarred = album.isStarred(); } |