From 4ae18241ec26a709ab303a5079843c4d3a9500fc Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 23 Nov 2015 17:47:01 -0800 Subject: #597 Unpin songs when no longer in synced playlist on manual refresh --- .../dsub/service/CachedMusicService.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'app/src/main/java/github') 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 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 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; } -- cgit v1.2.3