Show the number of downloaded episodes in stats screen (#7435)

This commit is contained in:
Tony Tam 2024-10-04 12:15:03 -07:00 committed by GitHub
parent 4990d95f33
commit a671be2d79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -77,7 +77,10 @@
<string name="section_shown">Shown</string> <string name="section_shown">Shown</string>
<!-- Download Statistics fragment --> <!-- Download Statistics fragment -->
<string name="total_size_downloaded_podcasts">Total size of episodes on the device</string> <plurals name="total_size_downloaded_podcasts">
<item quantity="one">Total size of %d episode on the device</item>
<item quantity="other">Total size of %d episodes on the device</item>
</plurals>
<!-- Main activity --> <!-- Main activity -->
<string name="drawer_open">Open menu</string> <string name="drawer_open">Open menu</string>

View File

@ -16,6 +16,7 @@ import java.util.List;
*/ */
public class DownloadStatisticsListAdapter extends StatisticsListAdapter { public class DownloadStatisticsListAdapter extends StatisticsListAdapter {
private final Fragment fragment; private final Fragment fragment;
private int cacheEpisodes;
public DownloadStatisticsListAdapter(Context context, Fragment fragment) { public DownloadStatisticsListAdapter(Context context, Fragment fragment) {
super(context); super(context);
@ -24,7 +25,8 @@ public class DownloadStatisticsListAdapter extends StatisticsListAdapter {
@Override @Override
protected String getHeaderCaption() { protected String getHeaderCaption() {
return context.getString(R.string.total_size_downloaded_podcasts); return context.getResources().getQuantityString(
R.plurals.total_size_downloaded_podcasts, cacheEpisodes, cacheEpisodes);
} }
@Override @Override
@ -35,9 +37,11 @@ public class DownloadStatisticsListAdapter extends StatisticsListAdapter {
@Override @Override
protected PieChartView.PieChartData generateChartData(List<StatisticsItem> statisticsData) { protected PieChartView.PieChartData generateChartData(List<StatisticsItem> statisticsData) {
float[] dataValues = new float[statisticsData.size()]; float[] dataValues = new float[statisticsData.size()];
cacheEpisodes = 0;
for (int i = 0; i < statisticsData.size(); i++) { for (int i = 0; i < statisticsData.size(); i++) {
StatisticsItem item = statisticsData.get(i); StatisticsItem item = statisticsData.get(i);
dataValues[i] = item.totalDownloadSize; dataValues[i] = item.totalDownloadSize;
cacheEpisodes += item.episodesDownloadCount;
} }
return new PieChartView.PieChartData(dataValues); return new PieChartView.PieChartData(dataValues);
} }