aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java')
-rw-r--r--src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java48
1 files changed, 26 insertions, 22 deletions
diff --git a/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java
index 24cb23e8..1b3780a3 100644
--- a/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java
+++ b/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java
@@ -52,31 +52,35 @@ 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));
+ try {
+ ArrayList<String> syncedList = SyncUtil.getSyncedMostRecent(context, instance);
+ MusicDirectory albumList = musicService.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(musicService.getMusicDirectory(album.getId(), album.getTitle(), true, context, null), context);
+ syncedList.add(album.getId());
+ updated = true;
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to get songs for " + album.getId() + " on " + Util.getServerName(context, instance));
+ }
}
}
}
- }
-
- if(updated) {
- FileUtil.serialize(context, podcastList, SyncUtil.getMostRecentSyncFile(context, instance));
+
+ if(updated) {
+ FileUtil.serialize(context, syncedList, SyncUtil.getMostRecentSyncFile(context, instance));
+ }
+ } catch(Exception e) {
+ Log.e(TAG, "Failed to get most recent list for " + Util.getServerName(context, instance));
}
}
}