diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-06-16 13:21:41 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-06-16 13:21:41 +0200 |
commit | 26c8772e0a60aa916dceff4ec4d4eb7af2a19460 (patch) | |
tree | 6d48ff67f4a5e207eca4111ca69da2084fe4353e /src/de/podfetcher/service | |
parent | c41605ef3b9a21025d3625d577b53d63f64f1074 (diff) | |
download | AntennaPod-26c8772e0a60aa916dceff4ec4d4eb7af2a19460.zip |
Cleaned up the Download requester
Diffstat (limited to 'src/de/podfetcher/service')
-rw-r--r-- | src/de/podfetcher/service/DownloadService.java | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/de/podfetcher/service/DownloadService.java b/src/de/podfetcher/service/DownloadService.java index bbd64d420..cafdeecab 100644 --- a/src/de/podfetcher/service/DownloadService.java +++ b/src/de/podfetcher/service/DownloadService.java @@ -154,18 +154,16 @@ public class DownloadService extends Service { } if (status == DownloadManager.STATUS_SUCCESSFUL) { - Feed feed = requester.getFeed(downloadId); - if (feed != null) { - handleCompletedFeedDownload(context, feed); - } else { - FeedImage image = requester.getFeedImage(downloadId); - if (image != null) { - handleCompletedImageDownload(context, image); - } else { - FeedMedia media = requester.getFeedMedia(downloadId); - if (media != null) { - handleCompletedFeedMediaDownload(context, media); - } + FeedFile download = requester.getFeedFile(downloadId); + if (download != null) { + if (download.getClass() == Feed.class) { + handleCompletedFeedDownload(context, (Feed) download); + } else if (download.getClass() == FeedImage.class) { + handleCompletedImageDownload(context, + (FeedImage) download); + } else if (download.getClass() == FeedMedia.class) { + handleCompletedFeedMediaDownload(context, + (FeedMedia) download); } } queryDownloads(); @@ -189,7 +187,8 @@ public class DownloadService extends Service { initiateShutdown(); } else { // update notification - notificationBuilder.setContentText(numOfDownloads + " Downloads left"); + notificationBuilder.setContentText(numOfDownloads + + " Downloads left"); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(NOTIFICATION_ID, notificationBuilder.getNotification()); } @@ -241,7 +240,7 @@ public class DownloadService extends Service { Log.d(TAG, "Feed has image; Downloading...."); requester.downloadImage(service, feed.getImage()); } - requester.removeFeed(feed); + requester.removeDownload(feed); cleanup(); @@ -274,7 +273,7 @@ public class DownloadService extends Service { @Override public void run() { image.setDownloaded(true); - requester.removeFeedImage(image); + requester.removeDownload(image); manager.setFeedImage(service, image); queryDownloads(); } @@ -293,7 +292,7 @@ public class DownloadService extends Service { @Override public void run() { - requester.removeFeedMedia(media); + requester.removeDownload(media); media.setDownloaded(true); // Get duration try { |