aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-10-05 17:24:29 -0700
committerScott Jackson <daneren2005@gmail.com>2015-10-05 17:24:29 -0700
commit4e4963ed23413543e2bc1b95343e8b34d913207d (patch)
tree3b116f53224e7794fea745e53c721885fe63f07a /app
parentf106f414f8c525bf31914b32d03f9a9f2ec4f5af (diff)
downloaddsub-4e4963ed23413543e2bc1b95343e8b34d913207d.tar.gz
dsub-4e4963ed23413543e2bc1b95343e8b34d913207d.tar.bz2
dsub-4e4963ed23413543e2bc1b95343e8b34d913207d.zip
#559 Fix queue saving trying to save offline id's
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/domain/MusicDirectory.java13
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java7
2 files changed, 17 insertions, 3 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/domain/MusicDirectory.java b/app/src/main/java/github/daneren2005/dsub/domain/MusicDirectory.java
index 42aa5288..42c97b9e 100644
--- a/app/src/main/java/github/daneren2005/dsub/domain/MusicDirectory.java
+++ b/app/src/main/java/github/daneren2005/dsub/domain/MusicDirectory.java
@@ -20,6 +20,7 @@ package github.daneren2005.dsub.domain;
import android.annotation.TargetApi;
import android.content.Context;
+import android.content.SharedPreferences;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.util.Log;
@@ -525,6 +526,18 @@ public class MusicDirectory implements Serializable {
this.closeness = closeness;
}
+ public boolean isOnlineId(Context context) {
+ try {
+ String cacheLocation = Util.getPreferences(context).getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, null);
+ return cacheLocation == null || id == null || id.indexOf(cacheLocation) == -1;
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to check online id validity");
+
+ // Err on the side of default functionality
+ return true;
+ }
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index 442d3dc1..d057c7fd 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -18,7 +18,6 @@
*/
package github.daneren2005.dsub.service;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -41,7 +40,6 @@ import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.PlayerQueue;
import github.daneren2005.dsub.domain.PlayerState;
import github.daneren2005.dsub.domain.ServerInfo;
-import github.daneren2005.dsub.util.BackgroundTask;
import github.daneren2005.dsub.util.CacheCleaner;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.FileUtil;
@@ -288,7 +286,10 @@ public class DownloadServiceLifecycleSupport {
public void serializeDownloadQueueNow(List<DownloadFile> songs, boolean serializeRemote) {
final PlayerQueue state = new PlayerQueue();
for (DownloadFile downloadFile : songs) {
- state.songs.add(downloadFile.getSong());
+ MusicDirectory.Entry song = downloadFile.getSong();
+ if(song.isOnlineId(downloadService)) {
+ state.songs.add(downloadFile.getSong());
+ }
}
for (DownloadFile downloadFile : downloadService.getToDelete()) {
state.toDelete.add(downloadFile.getSong());