diff options
author | Tom Hennen <tom.hennen@gmail.com> | 2015-04-16 20:09:11 -0400 |
---|---|---|
committer | Tom Hennen <tom.hennen@gmail.com> | 2015-04-16 20:09:11 -0400 |
commit | 0420bf47f48380f0b72fe245ac0990bb2cd7368d (patch) | |
tree | 8e8dc030ec3e894cee50591d5f856c1dbc32123c /core | |
parent | b0b228303c33550624835ecdb5f98c1d7c85dfe5 (diff) | |
download | AntennaPod-0420bf47f48380f0b72fe245ac0990bb2cd7368d.zip |
the most recent episode in new feeds is marked unplayed
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java | 10 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java | 16 |
2 files changed, 20 insertions, 6 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 c0f71ed55..90edd50bc 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,6 +350,16 @@ 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); + } + return null; + } + @Override public int getTypeAsInt() { return FEEDFILETYPE_FEED; 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 e0e370b0d..0624b0396 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 @@ -560,7 +560,7 @@ public final class DBTasks { /** * Adds new Feeds to the database or updates the old versions if they already exists. If another Feed with the same * identifying value already exists, this method will add new FeedItems from the new Feed to the existing Feed. - * These FeedItems will be marked as unread. + * These FeedItems will be marked as unread with the exception of the most recent FeedItem. * <p/> * This method can update multiple feeds at once. Submitting a feed twice in the same method call can result in undefined behavior. * <p/> @@ -586,12 +586,16 @@ public final class DBTasks { final Feed savedFeed = searchFeedByIdentifyingValueOrID(context, adapter, newFeed); if (savedFeed == null) { - if (BuildConfig.DEBUG) - Log.d(TAG, - "Found no existing Feed with title " - + newFeed.getTitle() + ". Adding as new one." - ); + Log.d(TAG, "Found no existing Feed with title " + + newFeed.getTitle() + ". Adding as new one."); + // Add a new Feed + // all new feeds will have the most recent item marked as unplayed + FeedItem mostRecent = newFeed.getMostRecentItem(false); + if (mostRecent != null) { + mostRecent.setRead(false); + } + newFeedsList.add(newFeed); resultFeeds[feedIdx] = newFeed; } else { |