aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-11-23 17:55:51 -0800
committerScott Jackson <daneren2005@gmail.com>2015-11-23 17:55:51 -0800
commitd230416c7ac38e87c26c0f7a016b4c222e1cdda6 (patch)
treebad69e2e7eb7b5759df976152499f41c722171b9 /app/src
parent4ae18241ec26a709ab303a5079843c4d3a9500fc (diff)
downloaddsub-d230416c7ac38e87c26c0f7a016b4c222e1cdda6.tar.gz
dsub-d230416c7ac38e87c26c0f7a016b4c222e1cdda6.tar.bz2
dsub-d230416c7ac38e87c26c0f7a016b4c222e1cdda6.zip
#597 Auto unpin songs when removing from playlist through DSub
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java24
1 files changed, 21 insertions, 3 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 9c87096c..caf000d4 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java
@@ -340,7 +340,7 @@ public class CachedMusicService implements MusicService {
}
@Override
- public void removeFromPlaylist(String id, final List<Integer> toRemove, Context context, ProgressListener progressListener) throws Exception {
+ public void removeFromPlaylist(final String id, final List<Integer> toRemove, Context context, ProgressListener progressListener) throws Exception {
musicService.removeFromPlaylist(id, toRemove, context, progressListener);
new MusicDirectoryUpdater(context, "playlist", id) {
@@ -351,9 +351,27 @@ public class CachedMusicService implements MusicService {
@Override
public void updateResult(List<Entry> objects, Entry result) {
+ // Make sure this playlist is supposed to be synced
+ boolean supposedToUnpin = false;
+ 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)) {
+ supposedToUnpin = true;
+ break;
+ }
+ }
+
// Remove in reverse order so indexes are still correct as we iterate through
for(ListIterator<Integer> iterator = toRemove.listIterator(toRemove.size()); iterator.hasPrevious(); ) {
- objects.remove((int) iterator.previous());
+ int index = iterator.previous();
+ if(supposedToUnpin) {
+ Entry entry = objects.get(index);
+ DownloadFile file = new DownloadFile(context, entry, true);
+ file.unpin();
+ }
+
+ objects.remove(index);
}
}
}.execute();
@@ -1217,7 +1235,7 @@ public class CachedMusicService implements MusicService {
public ArrayList<Entry> getArrayList() {
musicDirectory = FileUtil.deserialize(context, cacheName, MusicDirectory.class);
if(musicDirectory != null) {
- return new ArrayList<Entry>(musicDirectory.getChildren());
+ return new ArrayList<>(musicDirectory.getChildren());
} else {
return null;
}