diff options
author | daneren2005 <daneren2005@gmail.com> | 2013-12-09 16:07:01 -0800 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2013-12-09 16:07:01 -0800 |
commit | ba093211085e586380d89c9213a4a59c8de9aa81 (patch) | |
tree | 3d1ca93e425d1d537cba6fd576093c070633e5da /src | |
parent | 1f982aa8feff78afe099ea4721438f0ae126de4a (diff) | |
download | dsub-ba093211085e586380d89c9213a4a59c8de9aa81.tar.gz dsub-ba093211085e586380d89c9213a4a59c8de9aa81.tar.bz2 dsub-ba093211085e586380d89c9213a4a59c8de9aa81.zip |
#204 Add Recently Added sync logic
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java | 27 |
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));
+ }
}
}
|