Fixed items without pubdate getting assigned the current date on every single refresh
This commit is contained in:
parent
410ebfe98c
commit
ff116ccd8c
|
@ -352,7 +352,7 @@ public class Feed extends FeedFile implements ImageResource {
|
|||
Date mostRecentDate = new Date(0);
|
||||
FeedItem mostRecentItem = null;
|
||||
for (FeedItem item : items) {
|
||||
if (item.getPubDate().after(mostRecentDate)) {
|
||||
if (item.getPubDate() != null && item.getPubDate().after(mostRecentDate)) {
|
||||
mostRecentDate = item.getPubDate();
|
||||
mostRecentItem = item;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.xml.sax.SAXException;
|
|||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class FeedParserTask implements Callable<FeedHandlerResult> {
|
||||
|
@ -104,13 +103,6 @@ public class FeedParserTask implements Callable<FeedHandlerResult> {
|
|||
if (item.getTitle() == null) {
|
||||
throw new InvalidFeedException("Item has no title: " + item);
|
||||
}
|
||||
if (item.getPubDate() == null) {
|
||||
Log.e(TAG, "Item has no pubDate. Using current time as pubDate");
|
||||
if (item.getTitle() != null) {
|
||||
Log.e(TAG, "Title of invalid item: " + item.getTitle());
|
||||
}
|
||||
item.setPubDate(new Date());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.commons.io.FileUtils;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
@ -593,6 +594,11 @@ public class PodDBAdapter {
|
|||
* @return the id of the entry
|
||||
*/
|
||||
private long setFeedItem(FeedItem item, boolean saveFeed) {
|
||||
if (item.getId() == 0 && item.getPubDate() == null) {
|
||||
Log.e(TAG, "Newly saved item has no pubDate. Using current date as pubDate");
|
||||
item.setPubDate(new Date());
|
||||
}
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KEY_TITLE, item.getTitle());
|
||||
values.put(KEY_LINK, item.getLink());
|
||||
|
|
|
@ -4,16 +4,20 @@ import java.util.Comparator;
|
|||
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
|
||||
/** Compares the pubDate of two FeedItems for sorting*/
|
||||
/**
|
||||
* Compares the pubDate of two FeedItems for sorting.
|
||||
*/
|
||||
public class FeedItemPubdateComparator implements Comparator<FeedItem> {
|
||||
|
||||
/** Returns a new instance of this comparator in reverse order.
|
||||
public static FeedItemPubdateComparator newInstance() {
|
||||
FeedItemPubdateComparator
|
||||
}*/
|
||||
@Override
|
||||
public int compare(FeedItem lhs, FeedItem rhs) {
|
||||
return rhs.getPubDate().compareTo(lhs.getPubDate());
|
||||
}
|
||||
/**
|
||||
* Returns a new instance of this comparator in reverse order.
|
||||
*/
|
||||
@Override
|
||||
public int compare(FeedItem lhs, FeedItem rhs) {
|
||||
if (rhs.getPubDate() == null || lhs.getPubDate() == null) {
|
||||
return 0;
|
||||
}
|
||||
return rhs.getPubDate().compareTo(lhs.getPubDate());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue