diff options
Diffstat (limited to 'core/src/main/java/de')
3 files changed, 24 insertions, 7 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..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,6 +350,19 @@ public class Feed extends FeedFile implements FlattrThing, PicassoImageResource return false; } + 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 mostRecentItem; + } + @Override public int getTypeAsInt() { return FEEDFILETYPE_FEED; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/GpodnetSyncService.java b/core/src/main/java/de/danoeh/antennapod/core/service/GpodnetSyncService.java index e39197387..6e318dd36 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/GpodnetSyncService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/GpodnetSyncService.java @@ -176,7 +176,7 @@ public class GpodnetSyncService extends Service { private synchronized void processSubscriptionChanges(List<String> localSubscriptions, GpodnetSubscriptionChange changes) throws DownloadRequestException { for (String downloadUrl : changes.getAdded()) { if (!localSubscriptions.contains(downloadUrl)) { - Feed feed = new Feed(downloadUrl, new Date()); + Feed feed = new Feed(downloadUrl, new Date(0)); DownloadRequester.getInstance().downloadFeed(this, 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 9fa17bf72..7846f3dfc 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(); + if (mostRecent != null) { + mostRecent.setRead(false); + } + newFeedsList.add(newFeed); resultFeeds[feedIdx] = newFeed; } else { |