diff options
author | daneren2005 <daneren2005@gmail.com> | 2013-11-21 17:05:21 -0800 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2013-11-21 17:05:21 -0800 |
commit | c6e853e48d381f06c6555a41db11837dd6fa1240 (patch) | |
tree | b6b7267c4f1e8491545d36806815975d4ceed9d1 | |
parent | 085d8ce2f17d4f2321c97dee5f3909b0f9668b8e (diff) | |
download | dsub-c6e853e48d381f06c6555a41db11837dd6fa1240.tar.gz dsub-c6e853e48d381f06c6555a41db11837dd6fa1240.tar.bz2 dsub-c6e853e48d381f06c6555a41db11837dd6fa1240.zip |
Added playlist sync logic
-rw-r--r-- | src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java index bb07be47..e689f0c9 100644 --- a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java @@ -15,7 +15,7 @@ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
Copyright 2009 (C) Sindre Mehus
- */
+*/
package github.daneren2005.dsub.service.sync;
@@ -26,12 +26,15 @@ import android.content.ContentProviderClient; import android.content.Context;
import android.content.SyncResult;
import android.os.Bundle;
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.domain.Playlist;
+import github.daneren2005.dsub.util.Util;
/**
* Created by Scott on 8/28/13.
- */
+*/
-public class PlaylistSyncAdapter extends AbstractThreadedSyncAdapter {
+public class PlaylistSyncAdapter extends SubsonicSyncAdapter {
public PlaylistSyncAdapter(Context context, boolean autoInitialize) {
super(context, autoInitialize);
}
@@ -40,8 +43,21 @@ public class PlaylistSyncAdapter extends AbstractThreadedSyncAdapter { super(context, autoInitialize, allowParallelSyncs);
}
- @Override
- public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
-
+ @Override
+ public void onExecuteSync(Context context, int instance) {
+ String serverName = Util.getServerName(context, instance);
+ String playlistListFile = "sync-playlist-" + (Util.getRestUrl(context, null, instance)).hasCode() + ".ser";
+ List<Integer> playlistList = FileUtil.deserialize(context, playlistListFile, ArrayList.class);
+ for(int i = 0; i < playlistList.size(); i++) {
+ String id = Integer.toString(playlistList.get(i));
+ MusicDirectory playlist = musicService.getPlaylist(true, id, serverName, context, null);
+
+ for(MusicDirectory.Entry entry: playlist.getChildren()) {
+ DownloadFile file = new DownloadFile(context, entry, true);
+ if(!file.isSaved()) {
+ // TODO: Figure something out to download these one at a time!
+ }
+ }
+ }
}
}
|