diff --git a/src/de/danoeh/antennapod/feed/FeedImage.java b/src/de/danoeh/antennapod/feed/FeedImage.java index 4b53f3da4..72bdd195a 100644 --- a/src/de/danoeh/antennapod/feed/FeedImage.java +++ b/src/de/danoeh/antennapod/feed/FeedImage.java @@ -1,8 +1,8 @@ package de.danoeh.antennapod.feed; - public class FeedImage extends FeedFile { protected String title; + protected Feed feed; public FeedImage(String download_url, String title) { super(null, download_url, false); @@ -29,4 +29,12 @@ public class FeedImage extends FeedFile { this.title = title; } + public Feed getFeed() { + return feed; + } + + public void setFeed(Feed feed) { + this.feed = feed; + } + } diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java index 450bd8522..255ee4c1d 100644 --- a/src/de/danoeh/antennapod/feed/FeedManager.java +++ b/src/de/danoeh/antennapod/feed/FeedManager.java @@ -286,8 +286,6 @@ public class FeedManager { public void notifyInvalidImageFile(Context context, FeedImage image) { Log.i(TAG, "The feedmanager was notified about an invalid image download. It will now try to redownload the image file"); - image.setDownloaded(false); - image.setFile_url(null); requester.downloadImage(context, image); } @@ -695,6 +693,7 @@ public class FeedManager { .getLong(PodDBAdapter.KEY_IMAGE_INDEX); if (imageIndex != 0) { feed.setImage(adapter.getFeedImage(imageIndex)); + feed.getImage().setFeed(feed); } feed.file_url = feedlistCursor .getString(PodDBAdapter.KEY_FILE_URL_INDEX); diff --git a/src/de/danoeh/antennapod/service/DownloadService.java b/src/de/danoeh/antennapod/service/DownloadService.java index b322bdf28..ab871c564 100644 --- a/src/de/danoeh/antennapod/service/DownloadService.java +++ b/src/de/danoeh/antennapod/service/DownloadService.java @@ -223,6 +223,9 @@ public class DownloadService extends Service { status = c.getInt(c .getColumnIndex(DownloadManager.COLUMN_STATUS)); } + if (downloadId == 0) { + Log.d(TAG, "Download ID was null"); + } FeedFile download = requester.getFeedFile(downloadId); if (download != null) { if (status == DownloadManager.STATUS_SUCCESSFUL) { @@ -435,7 +438,8 @@ public class DownloadService extends Service { && savedFeed.getImage().isDownloaded() == false) { if (AppConfig.DEBUG) Log.d(TAG, "Feed has image; Downloading...."); - imageId = requester.downloadImage(service, feed.getImage()); + savedFeed.getImage().setFeed(savedFeed); + imageId = requester.downloadImage(service, savedFeed.getImage()); hasImage = true; } @@ -462,7 +466,7 @@ public class DownloadService extends Service { } requester.removeDownload(feed); - cleanup(); + //cleanup(); if (savedFeed == null) { savedFeed = feed; } @@ -519,8 +523,12 @@ public class DownloadService extends Service { true)); sendDownloadHandledIntent(image.getDownloadId(), statusId, false, 0); image.setDownloadId(0); - manager.setFeedImage(service, image); + if (image.getFeed() != null) { + manager.setFeed(service, image.getFeed()); + } else { + Log.e(TAG, "Image has no feed, image might not be saved correctly!"); + } queryDownloads(); } }