now actually using the date to figure out what is omst recent rather than just assuming it's the first

This commit is contained in:
Tom Hennen 2015-04-16 20:17:09 -04:00
parent 0420bf47f4
commit 4e9597a950
2 changed files with 11 additions and 8 deletions

View File

@ -350,14 +350,17 @@ public class Feed extends FeedFile implements FlattrThing, PicassoImageResource
return false;
}
public FeedItem getMostRecentItem(boolean enableEpisodeFilter) {
// we're going to assume the most recent item is the first one...
// we can sort later if needed
int numItems = getNumOfItems(enableEpisodeFilter);
if (numItems > 0) {
return getItemAtIndex(enableEpisodeFilter, 0);
public FeedItem getMostRecentItem() {
// we could sort, but we don't need to, a simple search is fine...
Date mostRecentDate = new Date(0);
FeedItem mostRecentItem = null;
for (FeedItem item : items) {
if (item.getPubDate().after(mostRecentDate)) {
mostRecentDate = item.getPubDate();
mostRecentItem = item;
}
}
return null;
return mostRecentItem;
}
@Override

View File

@ -591,7 +591,7 @@ public final class DBTasks {
// Add a new Feed
// all new feeds will have the most recent item marked as unplayed
FeedItem mostRecent = newFeed.getMostRecentItem(false);
FeedItem mostRecent = newFeed.getMostRecentItem();
if (mostRecent != null) {
mostRecent.setRead(false);
}