summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2020-02-01 19:08:11 +0100
committerByteHamster <info@bytehamster.com>2020-02-01 19:20:17 +0100
commitedef730bd4bb642cc3d0b8496be34ef3c8e59b20 (patch)
tree1f71617ac1dfa0cbc0d640c16c08e7b19ce2cb99 /core
parent63290ae762518c94563b8c128aef3eccc35d6fd9 (diff)
downloadAntennaPod-edef730bd4bb642cc3d0b8496be34ef3c8e59b20.zip
Clean up statistics
Removed unused `StatisticsData` wrapper class and extracted `StatisticsItem` to new class
Diffstat (limited to 'core')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java72
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/StatisticsItem.java51
2 files changed, 55 insertions, 68 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
index e6d21794c..e2da40ec3 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
@@ -866,17 +866,15 @@ public final class DBReader {
}
/**
- * Searches the DB for statistics
+ * Searches the DB for statistics.
*
- * @return The StatisticsInfo object
+ * @return The list of statistics objects
*/
@NonNull
- public static StatisticsData getStatistics() {
+ public static List<StatisticsItem> getStatistics() {
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
- long totalTimeCountAll = 0;
- long totalTime = 0;
List<StatisticsItem> feedTime = new ArrayList<>();
List<Feed> feeds = getFeedList();
@@ -922,72 +920,10 @@ public final class DBReader {
feedTime.add(new StatisticsItem(
feed, feedTotalTime, feedPlayedTime, feedPlayedTimeCountAll, episodes,
episodesStarted, episodesStartedIncludingMarked, totalDownloadSize));
- totalTime += feedPlayedTime;
- totalTimeCountAll += feedPlayedTimeCountAll;
}
adapter.close();
- return new StatisticsData(totalTime, totalTimeCountAll, feedTime);
- }
-
- public static class StatisticsData {
- /**
- * Simply sums up time of podcasts that are marked as played
- */
- public final long totalTimeCountAll;
-
- /**
- * Respects speed, listening twice, ...
- */
- public final long totalTime;
-
- public final List<StatisticsItem> feeds;
-
- public StatisticsData(long totalTime, long totalTimeCountAll, List<StatisticsItem> feeds) {
- this.totalTime = totalTime;
- this.totalTimeCountAll = totalTimeCountAll;
- this.feeds = feeds;
- }
- }
-
- public static class StatisticsItem {
- public final Feed feed;
- public final long time;
-
- /**
- * Respects speed, listening twice, ...
- */
- public final long timePlayed;
- /**
- * Simply sums up time of podcasts that are marked as played
- */
- public final long timePlayedCountAll;
- public final long episodes;
- /**
- * Episodes that are actually played
- */
- public final long episodesStarted;
- /**
- * All episodes that are marked as played (or have position != 0)
- */
- public final long episodesStartedIncludingMarked;
- /**
- * Simply sums up the size of download podcasts
- */
- public final long totalDownloadSize;
-
- public StatisticsItem(Feed feed, long time, long timePlayed, long timePlayedCountAll,
- long episodes, long episodesStarted, long episodesStartedIncludingMarked,
- long totalDownloadSize) {
- this.feed = feed;
- this.time = time;
- this.timePlayed = timePlayed;
- this.timePlayedCountAll = timePlayedCountAll;
- this.episodes = episodes;
- this.episodesStarted = episodesStarted;
- this.episodesStartedIncludingMarked = episodesStartedIncludingMarked;
- this.totalDownloadSize = totalDownloadSize;
- }
+ return feedTime;
}
/**
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/StatisticsItem.java b/core/src/main/java/de/danoeh/antennapod/core/storage/StatisticsItem.java
new file mode 100644
index 000000000..f96af185b
--- /dev/null
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/StatisticsItem.java
@@ -0,0 +1,51 @@
+package de.danoeh.antennapod.core.storage;
+
+import de.danoeh.antennapod.core.feed.Feed;
+
+public class StatisticsItem {
+ public final Feed feed;
+ public final long time;
+
+ /**
+ * Respects speed, listening twice, ...
+ */
+ public final long timePlayed;
+
+ /**
+ * Simply sums up time of podcasts that are marked as played.
+ */
+ public final long timePlayedCountAll;
+
+ /**
+ * Number of episodes.
+ */
+ public final long episodes;
+
+ /**
+ * Episodes that are actually played.
+ */
+ public final long episodesStarted;
+
+ /**
+ * All episodes that are marked as played (or have position != 0).
+ */
+ public final long episodesStartedIncludingMarked;
+
+ /**
+ * Simply sums up the size of download podcasts.
+ */
+ public final long totalDownloadSize;
+
+ public StatisticsItem(Feed feed, long time, long timePlayed, long timePlayedCountAll,
+ long episodes, long episodesStarted, long episodesStartedIncludingMarked,
+ long totalDownloadSize) {
+ this.feed = feed;
+ this.time = time;
+ this.timePlayed = timePlayed;
+ this.timePlayedCountAll = timePlayedCountAll;
+ this.episodes = episodes;
+ this.episodesStarted = episodesStarted;
+ this.episodesStartedIncludingMarked = episodesStartedIncludingMarked;
+ this.totalDownloadSize = totalDownloadSize;
+ }
+}