[Statistics]Add count of episodes stocked on device (#4581)

This commit is contained in:
avirajrsingh 2020-10-24 13:56:56 +05:30 committed by GitHub
parent 75b7b41fa0
commit 69a3c56d24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.text.format.Formatter;
import java.util.List;
import java.util.Locale;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.storage.StatisticsItem;
@ -40,7 +41,10 @@ public class DownloadStatisticsListAdapter extends StatisticsListAdapter {
@Override
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)));
}
}

View File

@ -746,6 +746,7 @@ public final class DBReader {
long episodesStarted = 0;
long episodesStartedIncludingMarked = 0;
long totalDownloadSize = 0;
long episodesDownloadCount = 0;
List<FeedItem> items = getFeed(feed.getId()).getItems();
for (FeedItem item : items) {
FeedMedia media = item.getMedia();
@ -773,13 +774,14 @@ public final class DBReader {
if (media.isDownloaded()) {
totalDownloadSize = totalDownloadSize + media.getSize();
episodesDownloadCount++;
}
episodes++;
}
feedTime.add(new StatisticsItem(
feed, feedTotalTime, feedPlayedTime, feedPlayedTimeCountAll, episodes,
episodesStarted, episodesStartedIncludingMarked, totalDownloadSize));
episodesStarted, episodesStartedIncludingMarked, totalDownloadSize, episodesDownloadCount));
}
adapter.close();

View File

@ -36,9 +36,14 @@ public class StatisticsItem {
*/
public final long totalDownloadSize;
/**
* Stores the number of episodes downloaded.
*/
public final long episodesDownloadCount;
public StatisticsItem(Feed feed, long time, long timePlayed, long timePlayedCountAll,
long episodes, long episodesStarted, long episodesStartedIncludingMarked,
long totalDownloadSize) {
long totalDownloadSize, long episodesDownloadCount) {
this.feed = feed;
this.time = time;
this.timePlayed = timePlayed;
@ -47,5 +52,6 @@ public class StatisticsItem {
this.episodesStarted = episodesStarted;
this.episodesStartedIncludingMarked = episodesStartedIncludingMarked;
this.totalDownloadSize = totalDownloadSize;
this.episodesDownloadCount = episodesDownloadCount;
}
}