diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-12-25 13:11:14 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-12-25 13:11:14 -0800 |
commit | 3f2a53de1f7f357b7bb2824684448cf94a468f73 (patch) | |
tree | 2a2989da5eebed3020886f205469a6f3bce1ce61 | |
parent | fa7631c85f6672773a2a07b0c921f29eddc1897a (diff) | |
download | dsub-3f2a53de1f7f357b7bb2824684448cf94a468f73.tar.gz dsub-3f2a53de1f7f357b7bb2824684448cf94a468f73.tar.bz2 dsub-3f2a53de1f7f357b7bb2824684448cf94a468f73.zip |
Unpin songs when turning off playlist sync
-rw-r--r-- | src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java index 615bbe71..fb3a254a 100644 --- a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java @@ -17,11 +17,14 @@ import android.widget.CheckBox; import android.widget.EditText;
import android.widget.ListView;
import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.Playlist;
+import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.service.OfflineException;
import github.daneren2005.dsub.service.ServerTooOldException;
+import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.ProgressListener;
import github.daneren2005.dsub.util.SyncUtil;
import github.daneren2005.dsub.util.BackgroundTask;
@@ -261,7 +264,27 @@ public class SelectPlaylistFragment extends SelectListFragment<Playlist> { downloadPlaylist(playlist.getId(), playlist.getName(), true, true, false, false, true);
}
- private void stopSyncPlaylist(Playlist playlist) {
+ private void stopSyncPlaylist(final Playlist playlist) {
SyncUtil.removeSyncedPlaylist(context, playlist.getId());
+
+ new LoadingTask<Void>(context, false) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ // Unpin all of the songs in playlist
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ MusicDirectory root = musicService.getPlaylist(true, playlist.getId(), playlist.getName(), context, this);
+ for(MusicDirectory.Entry entry: root.getChildren()) {
+ DownloadFile file = new DownloadFile(context, entry, false);
+ file.unpin();
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+
+ }
+ }.execute();
}
}
|