summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-08-11 13:12:47 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-08-11 13:12:47 +0200
commit9d2a8a7750b5849d16e4bc0556ab482b47c004fd (patch)
tree51d9c4df7033731560b6ad4f073c000ddb2fce6c /src/de
parentcd7c3682874e46b2f1c135e335ec7d99413b304f (diff)
downloadAntennaPod-9d2a8a7750b5849d16e4bc0556ab482b47c004fd.zip
Deleting a feed will now cancel running image and media downloads of
that feed
Diffstat (limited to 'src/de')
-rw-r--r--src/de/danoeh/antennapod/feed/FeedManager.java11
-rw-r--r--src/de/danoeh/antennapod/service/DownloadService.java9
2 files changed, 18 insertions, 2 deletions
diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java
index 255ee4c1d..981247792 100644
--- a/src/de/danoeh/antennapod/feed/FeedManager.java
+++ b/src/de/danoeh/antennapod/feed/FeedManager.java
@@ -38,7 +38,7 @@ public class FeedManager {
public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feed.feedId";
/** Number of completed Download status entries to store. */
- private static final int DOWNLOAD_LOG_SIZE = 25;
+ private static final int DOWNLOAD_LOG_SIZE = 50;
private static FeedManager singleton;
@@ -131,14 +131,17 @@ public class FeedManager {
/** Remove a feed with all its items and media files and its image. */
public void deleteFeed(final Context context, final Feed feed) {
PodDBAdapter adapter = new PodDBAdapter(context);
+ DownloadRequester requester = DownloadRequester.getInstance();
adapter.open();
// delete image file
if (feed.getImage() != null) {
if (feed.getImage().isDownloaded()
- && feed.getImage().getFile_url() == null) {
+ && feed.getImage().getFile_url() != null) {
File imageFile = new File(feed.getImage().getFile_url());
imageFile.delete();
}
+ } else if (requester.isDownloadingFile(feed.getImage())) {
+ requester.cancelDownload(context, feed.getImage().getDownloadId());
}
// delete stored media files and mark them as read
for (FeedItem item : feed.getItems()) {
@@ -151,6 +154,10 @@ public class FeedManager {
if (item.getMedia() != null && item.getMedia().isDownloaded()) {
File mediaFile = new File(item.getMedia().getFile_url());
mediaFile.delete();
+ } else if (item.getMedia() != null
+ && requester.isDownloadingFile(item.getMedia())) {
+ requester.cancelDownload(context, item.getMedia()
+ .getDownloadId());
}
}
diff --git a/src/de/danoeh/antennapod/service/DownloadService.java b/src/de/danoeh/antennapod/service/DownloadService.java
index ab871c564..30288efc0 100644
--- a/src/de/danoeh/antennapod/service/DownloadService.java
+++ b/src/de/danoeh/antennapod/service/DownloadService.java
@@ -7,6 +7,7 @@ package de.danoeh.antennapod.service;
import java.io.File;
import java.io.IOException;
+import java.lang.Thread.UncaughtExceptionHandler;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -115,6 +116,14 @@ public class DownloadService extends Service {
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setPriority(Thread.MIN_PRIORITY);
+ t.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
+
+ @Override
+ public void uncaughtException(Thread thread, Throwable ex) {
+ Log.e(TAG, "Thread exited with uncaught exception");
+ ex.printStackTrace();
+ queryDownloads();
+ }});
return t;
}
});