aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java
index 19637fcc..24cb23e8 100644
--- a/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java
+++ b/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java
@@ -52,6 +52,31 @@ public class MostRecentSyncAdapter extends SubsonicSyncAdapter {
@Override
public void onExecuteSync(Context context, int instance) {
-
+ List<String> syncedList = SyncUtil.getSyncedMostRecent(context, instance);
+ MusicDirectory albumList = service.getAlbumList("recent", 20, 0, context, null);
+ boolean updated = false;
+ if(syncedList.size() == 0) {
+ // Get the initial set of albums on first run, don't sync any of these!
+ for(MusicDirectory.Entry album: albumList.getChildren()) {
+ syncedList.add(album.getId());
+ }
+ updated = true;
+ } else {
+ for(MusicDirectory.Entry album: albumList.getChildren()) {
+ if(!syncedList.contains(album.getId()) {
+ try {
+ downloadRecursively(album, context);
+ syncedList.add(album.getId());
+ updated = true;
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to get songs for " + id + " on " + Util.getServerName(context, instance));
+ }
+ }
+ }
+ }
+
+ if(updated) {
+ FileUtil.serialize(context, podcastList, SyncUtil.getMostRecentSyncFile(context, instance));
+ }
}
}