mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-31 02:44:53 +01:00
Deleting a feed will now cancel running image and media downloads of
that feed
This commit is contained in:
parent
cd7c368287
commit
9d2a8a7750
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user