aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-01-04 19:19:18 -0800
committerScott Jackson <daneren2005@gmail.com>2014-01-04 19:19:18 -0800
commitf91d7473ce45f661ff2599841cf4464dd4973316 (patch)
tree455cb3521645413f97ff4e5d76a908594716ebe7 /src
parentec5cd33e92c2aed0026d6df7d08b1c3313a3afdf (diff)
downloaddsub-f91d7473ce45f661ff2599841cf4464dd4973316.tar.gz
dsub-f91d7473ce45f661ff2599841cf4464dd4973316.tar.bz2
dsub-f91d7473ce45f661ff2599841cf4464dd4973316.zip
Use AlbumView hack everywhere to fix delete, etc...
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/util/FileUtil.java28
-rw-r--r--src/github/daneren2005/dsub/view/AlbumView.java18
2 files changed, 23 insertions, 23 deletions
diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java
index 524cfe70..ebd2e8b9 100644
--- a/src/github/daneren2005/dsub/util/FileUtil.java
+++ b/src/github/daneren2005/dsub/util/FileUtil.java
@@ -187,17 +187,33 @@ public class FileUtil {
}
public static File getAlbumDirectory(Context context, MusicDirectory.Entry entry) {
- File dir;
+ File dir = null;
if (entry.getPath() != null) {
File f = new File(fileSystemSafeDir(entry.getPath()));
dir = new File(getMusicDirectory(context).getPath() + "/" + (entry.isDirectory() ? f.getPath() : f.getParent()));
} else {
- String artist = fileSystemSafe(entry.getArtist());
- String album = fileSystemSafe(entry.getAlbum());
- if("unnamed".equals(album)) {
- album = fileSystemSafe(entry.getTitle());
+ // 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 = "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();
+ }
+ }
+
+ if(dir == null) {
+ String artist = fileSystemSafe(entry.getArtist());
+ String album = fileSystemSafe(entry.getAlbum());
+ if("unnamed".equals(album)) {
+ album = fileSystemSafe(entry.getTitle());
+ }
+ dir = new File(getMusicDirectory(context).getPath() + "/" + artist + "/" + album);
}
- dir = new File(getMusicDirectory(context).getPath() + "/" + artist + "/" + album);
}
return dir;
}
diff --git a/src/github/daneren2005/dsub/view/AlbumView.java b/src/github/daneren2005/dsub/view/AlbumView.java
index af59165f..5083ef0b 100644
--- a/src/github/daneren2005/dsub/view/AlbumView.java
+++ b/src/github/daneren2005/dsub/view/AlbumView.java
@@ -80,23 +80,7 @@ public class AlbumView extends UpdateView {
@Override
protected void updateBackground() {
if(file == null) {
- String s = Util.getRestUrl(context, null, false) + 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);
- }
+ file = FileUtil.getAlbumDirectory(context, album);
}
exists = file.exists();