diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-09-23 10:37:43 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-09-23 10:37:43 +0200 |
commit | e38746f906f9ddfb7600b2113f8934bc4117e6ec (patch) | |
tree | 6b4933ad10cbede02c02ce203fce9ad8806e33e5 /src/de/danoeh/antennapod/storage/FeedItemStatistics.java | |
parent | aa3675bc838727f4e2b8bddbafa5972370f19cda (diff) | |
download | AntennaPod-e38746f906f9ddfb7600b2113f8934bc4117e6ec.zip |
Statistics for Feeds with no items are now loaded correctly. fixes #283
Diffstat (limited to 'src/de/danoeh/antennapod/storage/FeedItemStatistics.java')
-rw-r--r-- | src/de/danoeh/antennapod/storage/FeedItemStatistics.java | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/de/danoeh/antennapod/storage/FeedItemStatistics.java b/src/de/danoeh/antennapod/storage/FeedItemStatistics.java index 6b79dd144..8cb040756 100644 --- a/src/de/danoeh/antennapod/storage/FeedItemStatistics.java +++ b/src/de/danoeh/antennapod/storage/FeedItemStatistics.java @@ -11,13 +11,29 @@ public class FeedItemStatistics { private int numberOfNewItems; private int numberOfInProgressItems; private Date lastUpdate; + private static final Date UNKNOWN_DATE = new Date(0); + + /** + * Creates new FeedItemStatistics object. + * + * @param feedID ID of the feed. + * @param numberOfItems Number of items that this feed has. + * @param numberOfNewItems Number of unread items this feed has. + * @param numberOfInProgressItems Number of items that the user has started listening to. + * @param lastUpdate pubDate of the latest episode. A lastUpdate value of 0 will be interpreted as DATE_UNKOWN if + * numberOfItems is 0. + */ public FeedItemStatistics(long feedID, int numberOfItems, int numberOfNewItems, int numberOfInProgressItems, Date lastUpdate) { this.feedID = feedID; this.numberOfItems = numberOfItems; this.numberOfNewItems = numberOfNewItems; this.numberOfInProgressItems = numberOfInProgressItems; - this.lastUpdate = (lastUpdate != null) ? (Date) lastUpdate.clone() : null; + if (numberOfItems > 0) { + this.lastUpdate = (lastUpdate != null) ? (Date) lastUpdate.clone() : null; + } else { + this.lastUpdate = UNKNOWN_DATE; + } } public long getFeedID() { @@ -36,7 +52,19 @@ public class FeedItemStatistics { return numberOfInProgressItems; } + /** + * Returns the pubDate of the latest item in the feed. Users of this method + * should check if this value is unkown or not by calling lastUpdateKnown() first. + */ public Date getLastUpdate() { return (lastUpdate != null) ? (Date) lastUpdate.clone() : null; } + + /** + * Returns true if the lastUpdate value is known. The lastUpdate value is unkown if the + * feed has no items. + */ + public boolean lastUpdateKnown() { + return lastUpdate != UNKNOWN_DATE; + } } |