diff options
author | Daniel Oeh <daniel@daniel-pc.(none)> | 2011-12-28 18:04:34 +0100 |
---|---|---|
committer | Daniel Oeh <daniel@daniel-pc.(none)> | 2011-12-28 18:04:34 +0100 |
commit | 42576d50ccb5180ac1c9045bec95f2c0618f9be9 (patch) | |
tree | ab9c85cd486c53ce666adbbe8c0bd2880c82bfb4 /src/de/podfetcher/storage | |
parent | 5b11bc0bbf7a23c1382496662e4e45f76d3fbaf8 (diff) | |
download | AntennaPod-42576d50ccb5180ac1c9045bec95f2c0618f9be9.zip |
Added Methods for handling Image downloads
Diffstat (limited to 'src/de/podfetcher/storage')
-rw-r--r-- | src/de/podfetcher/storage/DownloadService.java | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/de/podfetcher/storage/DownloadService.java b/src/de/podfetcher/storage/DownloadService.java index b4a692f59..b7e7fdac3 100644 --- a/src/de/podfetcher/storage/DownloadService.java +++ b/src/de/podfetcher/storage/DownloadService.java @@ -54,16 +54,14 @@ public class DownloadService extends Service { Intent item_intent = requester.getItemIntent(id); String action = item_intent.getAction(); if(action.equals(DownloadRequester.ACTION_FEED_DOWNLOAD_COMPLETED)) { - handleCompletedFeedDownload(context, intent); - // Notify FeedSyncService about the new Feed - sendBroadcast(item_intent); + handleCompletedFeedDownload(context, item_intent); if(requester.getNumberOfFeedDownloads() == 0) { sendBroadcast(new Intent(ACTION_ALL_FEED_DOWNLOADS_COMPLETED)); } } else if(action.equals(DownloadRequester.ACTION_MEDIA_DOWNLOAD_COMPLETED)) { requester.removeMediaByID(item_intent.getLongExtra(DownloadRequester.EXTRA_ITEM_ID, -1)); } else if(action.equals(DownloadRequester.ACTION_IMAGE_DOWNLOAD_COMPLETED)) { - requester.removeImageByID(item_intent.getLongExtra(DownloadRequester.EXTRA_ITEM_ID, -1)); + handleCompletedImageDownload(context, item_intent); } // Check if there's something else to download, otherwise stop @@ -74,20 +72,29 @@ public class DownloadService extends Service { }; - /** Is called whenever a Feed is Downloaded */ + /** Is called whenever a Feed is downloaded */ private void handleCompletedFeedDownload(Context context, Intent intent) { - FeedHandler handler = new FeedHandler(); - requester.removeFeedByID(intent.getLongExtra(DownloadRequester.EXTRA_ITEM_ID, -1)); // Get Feed Information Feed feed = manager.getFeed(intent.getLongExtra(DownloadRequester.EXTRA_ITEM_ID, -1)); feed.setFile_url(requester.getFeedfilePath(context) + requester.getFeedfileName(feed.getId())); - feed = handler.parseFeed(feed); + // Update Information in Database + manager.setFeed(context, feed); // Download Feed Image if provided if(feed.getImage() != null) { requester.downloadImage(context, feed.getImage()); } - // Update Information in Database - manager.setFeed(context, feed); + // Notify FeedSyncService about the new Feed + sendBroadcast(item_intent); + + } + + /** Is called whenever a Feed-Image is downloaded */ + private void handleCompletedImageDownload(Context contex, Intent intent) { + requester.removeImageByID(item_intent.getLongExtra(DownloadRequester.EXTRA_ITEM_ID, -1)); + FeedImage image = manager.getFeedImage(item_intent.getLongExtra(DownloadRequester.EXTRA_ITEM_ID, -1)); + image.setFile_url(requester.getImagefilePath(context) + requester.getImagefileName(image.getId())); + sendBroadcast(item_intent); + } } |