mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-22 06:22:00 +01:00
Deleted DownloadReceiver
This commit is contained in:
parent
f751b3803b
commit
1f39a1a0f1
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user