diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-11-23 17:47:01 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-11-23 17:47:01 -0800 |
commit | 4ae18241ec26a709ab303a5079843c4d3a9500fc (patch) | |
tree | 6fad004bc8da87df36133235343dc50d904be7f8 /app/src/main/java | |
parent | 24bced19455b2e55919ef57fd33fdff3b8ed3db9 (diff) | |
download | dsub-4ae18241ec26a709ab303a5079843c4d3a9500fc.tar.gz dsub-4ae18241ec26a709ab303a5079843c4d3a9500fc.tar.bz2 dsub-4ae18241ec26a709ab303a5079843c4d3a9500fc.zip |
#597 Unpin songs when no longer in synced playlist on manual refresh
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java index 1a6658e3..9c87096c 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java @@ -53,6 +53,7 @@ import github.daneren2005.dsub.domain.Share; import github.daneren2005.dsub.domain.User; import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.ProgressListener; +import github.daneren2005.dsub.util.SyncUtil; import github.daneren2005.dsub.util.TimeLimitedCache; import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.Util; @@ -259,6 +260,26 @@ public class CachedMusicService implements MusicService { if(cachedPlaylist == null || !playlistFile.exists() || !cachedPlaylist.getChildren().equals(dir.getChildren())) { FileUtil.writePlaylistFile(context, playlistFile, dir); } + + if(cachedPlaylist != null) { + // Make sure this playlist is supposed to be synced + ArrayList<SyncUtil.SyncSet> playlistList = SyncUtil.getSyncedPlaylists(context, musicService.getInstance(context)); + for(int i = 0; i < playlistList.size(); i++) { + SyncUtil.SyncSet syncPlaylist = playlistList.get(i); + if(syncPlaylist.id != null && syncPlaylist.id.equals(id)) { + List<Entry> toDelete = cachedPlaylist.getChildren(); + for (Entry entry : dir.getChildren()) { + toDelete.remove(entry); + } + + for (Entry entry : toDelete) { + DownloadFile file = new DownloadFile(context, entry, true); + file.unpin(); + } + break; + } + } + } } return dir; } |