FeedSyncThread will now check if feeditems are valid before saving

This commit is contained in:
daniel oeh 2012-09-24 15:45:42 +02:00
parent 08983fcfe3
commit 337d82c64b
1 changed files with 26 additions and 4 deletions

View File

@ -49,6 +49,7 @@ import de.danoeh.antennapod.asynctask.DownloadStatus;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedFile;
import de.danoeh.antennapod.feed.FeedImage;
import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedManager;
import de.danoeh.antennapod.feed.FeedMedia;
import de.danoeh.antennapod.storage.DownloadRequestException;
@ -621,11 +622,32 @@ public class DownloadService extends Service {
if (feed.getTitle() == null) {
Log.e(TAG, "Feed has no title.");
return false;
} else {
if (AppConfig.DEBUG)
Log.d(TAG, "Feed appears to be valid.");
return true;
}
if (!hasValidFeedItems(feed)) {
Log.e(TAG, "Feed has invalid items");
return false;
}
if (AppConfig.DEBUG)
Log.d(TAG, "Feed appears to be valid.");
return true;
}
private boolean hasValidFeedItems(Feed feed) {
for (FeedItem item : feed.getItems()) {
if (item.getTitle() == null) {
Log.e(TAG, "Item has no title");
return false;
}
if (item.getPubDate() == null) {
Log.e(TAG, "Item has no pubDate");
if (item.getTitle() != null) {
Log.e(TAG, "Title of invalid item: " + item.getTitle());
}
return false;
}
}
return true;
}
/** Delete files that aren't needed anymore */