summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTom Hennen <tom.hennen@gmail.com>2015-04-16 20:17:09 -0400
committerTom Hennen <tom.hennen@gmail.com>2015-04-16 20:17:09 -0400
commit4e9597a95075e8384c6545b8d6c9a63be3c22e48 (patch)
treedc39c688f04896c1035f1a1f254663fb65396741 /core
parent0420bf47f48380f0b72fe245ac0990bb2cd7368d (diff)
downloadAntennaPod-4e9597a95075e8384c6545b8d6c9a63be3c22e48.zip
now actually using the date to figure out what is omst recent rather than just assuming it's the first
Diffstat (limited to 'core')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java17
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java2
2 files changed, 11 insertions, 8 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java b/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java
index 90edd50bc..8860653a1 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java
@@ -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
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
index 0624b0396..8dd6ddea7 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
@@ -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);
}