summaryrefslogtreecommitdiff
path: root/src/de/podfetcher
diff options
context:
space:
mode:
authorDaniel Oeh <daniel@daniel-pc.(none)>2011-12-24 12:12:08 +0100
committerDaniel Oeh <daniel@daniel-pc.(none)>2011-12-24 12:12:08 +0100
commit1f39a1a0f1f1b0667fc21a7a19b401d8d080a3f1 (patch)
tree7e346627dce9ba3b2cfc09e0a60bc0221f1f488a /src/de/podfetcher
parentf751b3803b49fa2d4f004d6ead11245bd1b65108 (diff)
downloadAntennaPod-1f39a1a0f1f1b0667fc21a7a19b401d8d080a3f1.zip
Deleted DownloadReceiver
Diffstat (limited to 'src/de/podfetcher')
-rw-r--r--src/de/podfetcher/storage/DownloadReceiver.java48
-rw-r--r--src/de/podfetcher/storage/DownloadRequester.java10
2 files changed, 9 insertions, 49 deletions
diff --git a/src/de/podfetcher/storage/DownloadReceiver.java b/src/de/podfetcher/storage/DownloadReceiver.java
deleted file mode 100644
index ed424eafb..000000000
--- a/src/de/podfetcher/storage/DownloadReceiver.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package de.podfetcher.storage;
-
-import de.podfetcher.PodcastApp;
-import de.podfetcher.feed.*;
-import android.app.DownloadManager;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-public class DownloadReceiver extends BroadcastReceiver {
- private DownloadRequester requester;
- private FeedManager manager;
-
- @Override
- public void onReceive(Context context, Intent intent) {
- long id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
- requester = DownloadRequester.getInstance();
- manager = FeedManager.getInstance();
- Intent item_intent = requester.getItemIntent(id);
- String action = item_intent.getAction();
- if(action.equals(DownloadRequester.ACTION_FEED_DOWNLOAD_COMPLETED)) {
- handleCompletedFeedDownload(context, intent);
- } 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));
- }
- PodcastApp.getInstance().getApplicationContext().sendBroadcast(item_intent);
- }
-
- /** 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.file_url = requester.getFeedfilePath(context) + requester.getFeedfileName(feed.id);
- feed = handler.parseFeed(feed);
- // Download Feed Image if provided
- if(feed.image != null) {
- requester.downloadImage(context, feed.image);
- }
- // Update Information in Database
- manager.setFeed(context, feed);
- }
-
-}
diff --git a/src/de/podfetcher/storage/DownloadRequester.java b/src/de/podfetcher/storage/DownloadRequester.java
index 7b6c5434b..4a3912c7f 100644
--- a/src/de/podfetcher/storage/DownloadRequester.java
+++ b/src/de/podfetcher/storage/DownloadRequester.java
@@ -69,7 +69,7 @@ public class DownloadRequester {
public void downloadImage(Context context, FeedImage image) {
download(context, images, image.download_url,
- new File(context.getExternalFilesDir(IMAGE_DOWNLOADPATH), "image-" + image.id),
+ new File(getImagefilePath, getImagefileName(image.id)),
true, ACTION_IMAGE_DOWNLOAD_COMPLETED, image.id);
}
@@ -145,4 +145,12 @@ public class DownloadRequester {
public String getFeedfileName(long id) {
return "feed-" + id;
}
+
+ public String getImagefilePath(Context context) {
+ return context.getExternalFilesDir(IMAGE_DOWNLOADPATH).toString();
+ }
+
+ public String getImagefileName(long id) {
+ return "image-" + id;
+ }
}