aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-06-20 21:03:56 -0700
committerScott Jackson <daneren2005@gmail.com>2013-06-20 21:03:56 -0700
commit32f95efa11b0754adf27e9c8b057da1083761705 (patch)
tree3977a1e4b5ad776571e08043ff5044574da43590 /subsonic-android/src
parent6d82bc108e596f0f09a699b599213e09fbaf1fa6 (diff)
downloaddsub-32f95efa11b0754adf27e9c8b057da1083761705.tar.gz
dsub-32f95efa11b0754adf27e9c8b057da1083761705.tar.bz2
dsub-32f95efa11b0754adf27e9c8b057da1083761705.zip
Add add to playlist for offline songs while in online mode + abstracted out song search
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java44
1 files changed, 19 insertions, 25 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
index 73a9f43b..953f10e2 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -427,7 +427,7 @@ public class RESTMusicService implements MusicService {
values.add(id);
for(MusicDirectory.Entry song: toAdd) {
names.add("songIdToAdd");
- values.add(song.getId());
+ values.add(getOfflineSongId(song.getId(), context, progressListener));
}
Reader reader = getReader(context, progressListener, "updatePlaylist", null, names, values);
try {
@@ -504,19 +504,8 @@ public class RESTMusicService implements MusicService {
@Override
public void scrobble(String id, boolean submission, 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 && submission) {
- String scrobbleSearchCriteria = Util.parseOfflineIDSearch(context, id, cacheLocn);
- SearchCritera critera = new SearchCritera(scrobbleSearchCriteria, 0, 0, 1);
- SearchResult result = searchNew(critera, context, progressListener);
- if(result.getSongs().size() == 1){
- scrobble(result.getSongs().get(0).getId(), true, 0, context, progressListener);
- }
- } else {
- scrobble(id, submission, 0, context, progressListener);
- }
+ id = getOfflineSongId(id, context, progressListener);
+ scrobble(id, submission, 0, context, progressListener);
}
public void scrobble(String id, boolean submission, long time, Context context, ProgressListener progressListener) throws Exception {
@@ -791,17 +780,7 @@ public class RESTMusicService implements MusicService {
@Override
public void setStarred(String id, boolean starred, Context context, ProgressListener progressListener) throws Exception {
checkServerVersion(context, "1.8", "Starring is not supported.");
-
- SharedPreferences prefs = Util.getPreferences(context);
- String cacheLocn = prefs.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, null);
- if(id.indexOf(cacheLocn) != -1) {
- String searchCriteria = Util.parseOfflineIDSearch(context, id, cacheLocn);
- SearchCritera critera = new SearchCritera(searchCriteria, 0, 0, 1);
- SearchResult result = searchNew(critera, context, progressListener);
- if(result.getSongs().size() == 1){
- id = result.getSongs().get(0).getId();
- }
- }
+ id = getOfflineSongId(id, context, progressListener);
Reader reader = getReader(context, progressListener, starred ? "star" : "unstar", null, "id", id);
try {
@@ -944,6 +923,21 @@ public class RESTMusicService implements MusicService {
return count - retry;
}
+
+ private String getOfflineSongId(String id, 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 searchCriteria = Util.parseOfflineIDSearch(context, id, cacheLocn);
+ SearchCritera critera = new SearchCritera(searchCriteria, 0, 0, 1);
+ SearchResult result = searchNew(critera, context, progressListener);
+ if(result.getSongs().size() == 1){
+ id = result.getSongs().get(0).getId();
+ }
+ }
+
+ return id;
+ }
private Reader getReader(Context context, ProgressListener progressListener, String method, HttpParams requestParams) throws Exception {
return getReader(context, progressListener, method, requestParams, Collections.<String>emptyList(), Collections.emptyList());