aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-11-26 22:23:38 -0800
committerScott Jackson <daneren2005@gmail.com>2013-11-26 22:23:38 -0800
commitf792e70df9a953bc4b7189e0847c7245c914a43e (patch)
tree988384fdf7bbe507a32cb19067b37826321a4b9e /src
parent36179619de6c68fb6faede4fc99494389df93cbd (diff)
downloaddsub-f792e70df9a953bc4b7189e0847c7245c914a43e.tar.gz
dsub-f792e70df9a953bc4b7189e0847c7245c914a43e.tar.bz2
dsub-f792e70df9a953bc4b7189e0847c7245c914a43e.zip
Use two try/catch blocks
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java66
1 files changed, 35 insertions, 31 deletions
diff --git a/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java
index 2aaa7a53..3b67125e 100644
--- a/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java
+++ b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java
@@ -54,42 +54,46 @@ public class PodcastSyncAdapter extends SubsonicSyncAdapter {
public void onExecuteSync(Context context, int instance) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
ArrayList<SyncSet> podcastList = SyncUtil.getSyncedPodcasts(context, instance);
-
- // Only refresh if syncs exist (implies a server where supported)
- if(podcastList.size() > 0) {
- // Refresh podcast listings before syncing
- musicService.refreshPodcasts(context, null);
- }
-
- boolean updated = false;
- for(int i = 0; i < podcastList.size(); i++) {
- SyncSet set = podcastList.get(i);
- String id = set.id;
- List<String> existingEpisodes = set.synced;
- try {
- MusicDirectory podcasts = musicService.getPodcastEpisodes(true, id, context, null);
-
- for(MusicDirectory.Entry entry: podcasts.getChildren()) {
- // Make sure podcast is valid and not already synced
- if(entry.getId() != null && "completed".equals(((PodcastEpisode)entry).getStatus()) && !existingEpisodes.contains(entry.getId())) {
- DownloadFile file = new DownloadFile(context, entry, true);
- while(!file.isSaved() && !file.isFailedMax()) {
- file.downloadNow();
- }
- // Only add if actualy downloaded correctly
- if(file.isSaved()) {
- existingEpisodes.add(entry.getId());
+
+ try {
+ // Only refresh if syncs exist (implies a server where supported)
+ if(podcastList.size() > 0) {
+ // Refresh podcast listings before syncing
+ musicService.refreshPodcasts(context, null);
+ }
+
+ boolean updated = false;
+ for(int i = 0; i < podcastList.size(); i++) {
+ SyncSet set = podcastList.get(i);
+ String id = set.id;
+ List<String> existingEpisodes = set.synced;
+ try {
+ MusicDirectory podcasts = musicService.getPodcastEpisodes(true, id, context, null);
+
+ for(MusicDirectory.Entry entry: podcasts.getChildren()) {
+ // Make sure podcast is valid and not already synced
+ if(entry.getId() != null && "completed".equals(((PodcastEpisode)entry).getStatus()) && !existingEpisodes.contains(entry.getId())) {
+ DownloadFile file = new DownloadFile(context, entry, true);
+ while(!file.isSaved() && !file.isFailedMax()) {
+ file.downloadNow();
+ }
+ // Only add if actualy downloaded correctly
+ if(file.isSaved()) {
+ existingEpisodes.add(entry.getId());
+ }
}
}
+ } catch (Exception e) {
+ Log.w(TAG, "Failed to get podcasts for " + id + " on " + Util.getServerName(context, instance));
}
- } catch(Exception e) {
- Log.e(TAG, "Failed to get podcasts for " + Util.getServerName(context, instance));
}
- }
- // Make sure there are is at least one change before re-syncing
- if(updated) {
- FileUtil.serialize(context, podcastList, SyncUtil.getPodcastSyncFile(context, instance));
+ // Make sure there are is at least one change before re-syncing
+ if(updated) {
+ FileUtil.serialize(context, podcastList, SyncUtil.getPodcastSyncFile(context, instance));
+ }
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to get podcasts for " + Util.getServerName(context, instance));
}
}
}