summaryrefslogtreecommitdiff
path: root/ui/statistics
diff options
context:
space:
mode:
authorTacoTheDank <SkytkRSfan3895@gmail.com>2024-03-06 02:52:14 -0500
committerTacoTheDank <SkytkRSfan3895@gmail.com>2024-03-06 02:52:14 -0500
commitc2ccc28b9513dab91e006681fd0c8fafac275623 (patch)
tree92fb4736066544322a08481fcd5d5db74b642ca6 /ui/statistics
parent6f582e4c52ae5f6f31b2014110823f561f5eb34b (diff)
downloadAntennaPod-c2ccc28b9513dab91e006681fd0c8fafac275623.zip
Update SpotBugs
Diffstat (limited to 'ui/statistics')
-rw-r--r--ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/BarChartView.java12
-rw-r--r--ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/YearStatisticsListAdapter.java30
2 files changed, 21 insertions, 21 deletions
diff --git a/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/BarChartView.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/BarChartView.java
index eadbb29ee..93b9e3332 100644
--- a/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/BarChartView.java
+++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/BarChartView.java
@@ -49,7 +49,7 @@ public class BarChartView extends AppCompatImageView {
drawable.data = data;
drawable.maxValue = 1;
for (DBReader.MonthlyStatisticsItem item : data) {
- drawable.maxValue = Math.max(drawable.maxValue, item.timePlayed);
+ drawable.maxValue = Math.max(drawable.maxValue, item.getTimePlayed());
}
}
@@ -89,21 +89,21 @@ public class BarChartView extends AppCompatImageView {
paintBars.setStrokeWidth(height * 0.015f);
paintBars.setColor(colors[0]);
int colorIndex = 0;
- int lastYear = data.size() > 0 ? data.get(0).year : 0;
+ int lastYear = data.size() > 0 ? data.get(0).getYear() : 0;
for (int i = 0; i < data.size(); i++) {
float x = textPadding + (i + 1) * stepSize;
- if (lastYear != data.get(i).year) {
- lastYear = data.get(i).year;
+ if (lastYear != data.get(i).getYear()) {
+ lastYear = data.get(i).getYear();
colorIndex++;
paintBars.setColor(colors[colorIndex % 2]);
if (i < data.size() - 2) {
- canvas.drawText(String.valueOf(data.get(i).year), x + stepSize,
+ canvas.drawText(String.valueOf(data.get(i).getYear()), x + stepSize,
barHeight + (height - barHeight + textSize) / 2, paintGridText);
}
canvas.drawLine(x, height, x, barHeight, paintGridText);
}
- float valuePercentage = (float) Math.max(0.005, (float) data.get(i).timePlayed / maxValue);
+ float valuePercentage = (float) Math.max(0.005, (float) data.get(i).getTimePlayed() / maxValue);
float y = (1 - valuePercentage) * barHeight;
canvas.drawRect(x, y, x + stepSize * 0.95f, barHeight, paintBars);
}
diff --git a/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/YearStatisticsListAdapter.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/YearStatisticsListAdapter.java
index 2116a17a4..d000ceb62 100644
--- a/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/YearStatisticsListAdapter.java
+++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/YearStatisticsListAdapter.java
@@ -57,41 +57,41 @@ public class YearStatisticsListAdapter extends RecyclerView.Adapter<RecyclerView
} else {
StatisticsHolder holder = (StatisticsHolder) h;
DBReader.MonthlyStatisticsItem statsItem = yearlyAggregate.get(position - 1);
- holder.year.setText(String.format(Locale.getDefault(), "%d ", statsItem.year));
- holder.hours.setText(String.format(Locale.getDefault(), "%.1f ", statsItem.timePlayed / 3600000.0f)
+ holder.year.setText(String.format(Locale.getDefault(), "%d ", statsItem.getYear()));
+ holder.hours.setText(String.format(Locale.getDefault(), "%.1f ", statsItem.getTimePlayed() / 3600000.0f)
+ context.getString(R.string.time_hours));
}
}
public void update(List<DBReader.MonthlyStatisticsItem> statistics) {
- int lastYear = statistics.size() > 0 ? statistics.get(0).year : 0;
- int lastDataPoint = statistics.size() > 0 ? (statistics.get(0).month - 1) + lastYear * 12 : 0;
+ int lastYear = statistics.size() > 0 ? statistics.get(0).getYear() : 0;
+ int lastDataPoint = statistics.size() > 0 ? (statistics.get(0).getMonth() - 1) + lastYear * 12 : 0;
long yearSum = 0;
yearlyAggregate.clear();
statisticsData.clear();
for (DBReader.MonthlyStatisticsItem statistic : statistics) {
- if (statistic.year != lastYear) {
+ if (statistic.getYear() != lastYear) {
DBReader.MonthlyStatisticsItem yearAggregate = new DBReader.MonthlyStatisticsItem();
- yearAggregate.year = lastYear;
- yearAggregate.timePlayed = yearSum;
+ yearAggregate.setYear(lastYear);
+ yearAggregate.setTimePlayed(yearSum);
yearlyAggregate.add(yearAggregate);
yearSum = 0;
- lastYear = statistic.year;
+ lastYear = statistic.getYear();
}
- yearSum += statistic.timePlayed;
- while (lastDataPoint + 1 < (statistic.month - 1) + statistic.year * 12) {
+ yearSum += statistic.getTimePlayed();
+ while (lastDataPoint + 1 < (statistic.getMonth() - 1) + statistic.getYear() * 12) {
lastDataPoint++;
DBReader.MonthlyStatisticsItem item = new DBReader.MonthlyStatisticsItem();
- item.year = lastDataPoint / 12;
- item.month = lastDataPoint % 12 + 1;
+ item.setYear(lastDataPoint / 12);
+ item.setMonth(lastDataPoint % 12 + 1);
statisticsData.add(item); // Compensate for months without playback
}
statisticsData.add(statistic);
- lastDataPoint = (statistic.month - 1) + statistic.year * 12;
+ lastDataPoint = (statistic.getMonth() - 1) + statistic.getYear() * 12;
}
DBReader.MonthlyStatisticsItem yearAggregate = new DBReader.MonthlyStatisticsItem();
- yearAggregate.year = lastYear;
- yearAggregate.timePlayed = yearSum;
+ yearAggregate.setYear(lastYear);
+ yearAggregate.setTimePlayed(yearSum);
yearlyAggregate.add(yearAggregate);
Collections.reverse(yearlyAggregate);
notifyDataSetChanged();