diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-12-11 21:02:11 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-12-11 21:02:11 -0800 |
commit | 629e0f03bbc1488d522e20aaefad1e50d0387e91 (patch) | |
tree | c137887e395581dcbcbef6542377f2ca16f5b66e /src | |
parent | 223e50347502bb66041b4881e110fe4b7f1cee77 (diff) | |
download | dsub-629e0f03bbc1488d522e20aaefad1e50d0387e91.tar.gz dsub-629e0f03bbc1488d522e20aaefad1e50d0387e91.tar.bz2 dsub-629e0f03bbc1488d522e20aaefad1e50d0387e91.zip |
#212 Added starred item sync logic
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java index 6eb58ed7..cc9db1f8 100644 --- a/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java @@ -23,16 +23,13 @@ import android.annotation.TargetApi; import android.content.Context;
import android.util.Log;
-import java.text.SimpleDateFormat;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
import github.daneren2005.dsub.domain.MusicDirectory;
-import github.daneren2005.dsub.domain.PodcastEpisode;
-import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.SyncUtil;
-import github.daneren2005.dsub.util.SyncUtil.SyncSet;
import github.daneren2005.dsub.util.Util;
/**
@@ -52,6 +49,29 @@ public class StarredSyncAdapter extends SubsonicSyncAdapter { @Override
public void onExecuteSync(Context context, int instance) {
+ try {
+ ArrayList<String> syncedList = new ArrayList<String>();
+ MusicDirectory starredList = musicService.getStarredList(context, null);
+ // Pin all the starred stuff
+ downloadRecursively(syncedList, starredList, context, true);
+
+ // Get old starred list
+ ArrayList<String> oldSyncedList = SyncUtil.getSyncedStarred(context, instance);
+
+ // Check to make sure there aren't any old starred songs that now need to be removed
+ oldSyncedList.removeAll(syncedList);
+
+ for(String path: oldSyncedList) {
+ File file = new File(path);
+ if(!file.delete()) {
+ Log.w(TAG, "Failed to delete " + path);
+ }
+ }
+
+ FileUtil.serialize(context, syncedList, SyncUtil.getStarredSyncFile(context, instance));
+ } catch(Exception e) {
+ Log.e(TAG, "Failed to get starred list for " + Util.getServerName(context, instance));
+ }
}
}
|