mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-02-02 19:56:59 +01:00
[Statistics]Add count of episodes stocked on device (#4581)
This commit is contained in:
parent
75b7b41fa0
commit
69a3c56d24
@ -4,6 +4,7 @@ import android.content.Context;
|
|||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.core.storage.StatisticsItem;
|
import de.danoeh.antennapod.core.storage.StatisticsItem;
|
||||||
@ -40,7 +41,10 @@ public class DownloadStatisticsListAdapter extends StatisticsListAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onBindFeedViewHolder(StatisticsHolder holder, StatisticsItem item) {
|
void onBindFeedViewHolder(StatisticsHolder holder, StatisticsItem item) {
|
||||||
holder.value.setText(Formatter.formatShortFileSize(context, item.totalDownloadSize));
|
holder.value.setText(Formatter.formatShortFileSize(context, item.totalDownloadSize)
|
||||||
|
+ " • "
|
||||||
|
+ String.format(Locale.getDefault(), "%d%s",
|
||||||
|
item.episodesDownloadCount, context.getString(R.string.episodes_suffix)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -746,6 +746,7 @@ public final class DBReader {
|
|||||||
long episodesStarted = 0;
|
long episodesStarted = 0;
|
||||||
long episodesStartedIncludingMarked = 0;
|
long episodesStartedIncludingMarked = 0;
|
||||||
long totalDownloadSize = 0;
|
long totalDownloadSize = 0;
|
||||||
|
long episodesDownloadCount = 0;
|
||||||
List<FeedItem> items = getFeed(feed.getId()).getItems();
|
List<FeedItem> items = getFeed(feed.getId()).getItems();
|
||||||
for (FeedItem item : items) {
|
for (FeedItem item : items) {
|
||||||
FeedMedia media = item.getMedia();
|
FeedMedia media = item.getMedia();
|
||||||
@ -773,13 +774,14 @@ public final class DBReader {
|
|||||||
|
|
||||||
if (media.isDownloaded()) {
|
if (media.isDownloaded()) {
|
||||||
totalDownloadSize = totalDownloadSize + media.getSize();
|
totalDownloadSize = totalDownloadSize + media.getSize();
|
||||||
|
episodesDownloadCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
episodes++;
|
episodes++;
|
||||||
}
|
}
|
||||||
feedTime.add(new StatisticsItem(
|
feedTime.add(new StatisticsItem(
|
||||||
feed, feedTotalTime, feedPlayedTime, feedPlayedTimeCountAll, episodes,
|
feed, feedTotalTime, feedPlayedTime, feedPlayedTimeCountAll, episodes,
|
||||||
episodesStarted, episodesStartedIncludingMarked, totalDownloadSize));
|
episodesStarted, episodesStartedIncludingMarked, totalDownloadSize, episodesDownloadCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter.close();
|
adapter.close();
|
||||||
|
@ -36,9 +36,14 @@ public class StatisticsItem {
|
|||||||
*/
|
*/
|
||||||
public final long totalDownloadSize;
|
public final long totalDownloadSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the number of episodes downloaded.
|
||||||
|
*/
|
||||||
|
public final long episodesDownloadCount;
|
||||||
|
|
||||||
public StatisticsItem(Feed feed, long time, long timePlayed, long timePlayedCountAll,
|
public StatisticsItem(Feed feed, long time, long timePlayed, long timePlayedCountAll,
|
||||||
long episodes, long episodesStarted, long episodesStartedIncludingMarked,
|
long episodes, long episodesStarted, long episodesStartedIncludingMarked,
|
||||||
long totalDownloadSize) {
|
long totalDownloadSize, long episodesDownloadCount) {
|
||||||
this.feed = feed;
|
this.feed = feed;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.timePlayed = timePlayed;
|
this.timePlayed = timePlayed;
|
||||||
@ -47,5 +52,6 @@ public class StatisticsItem {
|
|||||||
this.episodesStarted = episodesStarted;
|
this.episodesStarted = episodesStarted;
|
||||||
this.episodesStartedIncludingMarked = episodesStartedIncludingMarked;
|
this.episodesStartedIncludingMarked = episodesStartedIncludingMarked;
|
||||||
this.totalDownloadSize = totalDownloadSize;
|
this.totalDownloadSize = totalDownloadSize;
|
||||||
|
this.episodesDownloadCount = episodesDownloadCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user