diff options
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/domain/MusicDirectory.java | 13 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 7 |
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()); |