Image might not have been saved correctly after download

This commit is contained in:
daniel oeh 2012-08-11 12:47:43 +02:00
parent 1c24794ed2
commit cd7c368287
3 changed files with 21 additions and 6 deletions

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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();
}
}