aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-06-17 22:29:57 -0700
committerScott Jackson <daneren2005@gmail.com>2013-06-17 22:29:57 -0700
commit87da78de824d57f0cd132dabcf9effa3d331faaf (patch)
treec19271bd5ff58701fa3825fad4bfbb21ad39d69f /subsonic-android
parentd593f8cfd55843ae6cde5a8de2118097e7b727e4 (diff)
downloaddsub-87da78de824d57f0cd132dabcf9effa3d331faaf.tar.gz
dsub-87da78de824d57f0cd132dabcf9effa3d331faaf.tar.bz2
dsub-87da78de824d57f0cd132dabcf9effa3d331faaf.zip
Fix using Show Album on songs added in offline mode
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java13
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/Util.java18
2 files changed, 27 insertions, 4 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
index ee8a384c..75867fdc 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -274,6 +274,19 @@ public class RESTMusicService implements MusicService {
@Override
public MusicDirectory getMusicDirectory(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
+ SharedPreferences prefs = Util.getPreferences(context);
+ String cacheLocn = prefs.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, null);
+ if(id.indexOf(cacheLocn) != -1) {
+ String search = Util.parseOfflineIDSearch(context, id, cacheLocn);
+ SearchCritera critera = new SearchCritera(search, 1, 1, 0);
+ SearchResult result = searchNew(critera, context, progressListener);
+ if(result.getArtists().size() == 1) {
+ id = result.getArtists().get(0).getId();
+ } else if(result.getAlbums().size() == 1) {
+ id = result.getAlbums().get(0).getId();
+ }
+ }
+
Reader reader = getReader(context, progressListener, "getMusicDirectory", null, "id", id);
try {
return new MusicDirectoryParser(context).parse(name, reader, progressListener);
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
index 3ad4c623..98b9fc42 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
@@ -378,11 +378,21 @@ public final class Util {
name = index == -1 ? name : name.substring(0, index);
String[] details = name.split("/");
- String artist = "artist:\"" + details[0] + "\"";
String title = details[details.length - 1];
- title = "title:\"" + title.substring(title.indexOf('-') + 1) + "\"";
-
- name = artist + " AND " + title;
+ if(index == -1) {
+ if(details.length > 1) {
+ String artist = "artist:\"" + details[details.length - 2] + "\"";
+ String simpleArtist = "artist:\"" + title + "\"";
+ title = "album:\"" + title + "\"";
+ name = "(" + artist + " AND " + title + ")" + " OR " + simpleArtist;
+ } else {
+ name = "artist:\"" + title + "\"";
+ }
+ } else {
+ String artist = "artist:\"" + details[details.length - 3] + "\"";
+ title = "title:\"" + title.substring(title.indexOf('-') + 1) + "\"";
+ name = artist + " AND " + title;
+ }
return name;
}