From 708d8c05b819a40267e95a7ff42ada0ac94896bb Mon Sep 17 00:00:00 2001 From: Adrian Cotfas Date: Wed, 3 Nov 2021 20:03:14 +0200 Subject: [PATCH] Statistics: fix crash due to division by 0 --- app/build.gradle | 2 +- .../adrcotfas/goodtime/statistics/main/StatisticsFragment.kt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ad21005e..1387ff0a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,7 +14,7 @@ android { applicationId "com.apps.adrcotfas.goodtime" minSdkVersion 23 targetSdkVersion 30 - versionCode 136 + versionCode 137 versionName "2.5.0" resConfigs "ar-rSA", "bn-rBD", diff --git a/app/src/main/java/com/apps/adrcotfas/goodtime/statistics/main/StatisticsFragment.kt b/app/src/main/java/com/apps/adrcotfas/goodtime/statistics/main/StatisticsFragment.kt index 2224defb..4f04a7bc 100644 --- a/app/src/main/java/com/apps/adrcotfas/goodtime/statistics/main/StatisticsFragment.kt +++ b/app/src/main/java/com/apps/adrcotfas/goodtime/statistics/main/StatisticsFragment.kt @@ -786,6 +786,7 @@ class StatisticsFragment : Fragment() { ChartMarker.MarkerType.PERCENTAGE ) setScaleEnabled(false) + //TODO: do we need these here? invalidate() notifyDataSetChanged() } @@ -822,7 +823,7 @@ class StatisticsFragment : Fragment() { } for (i in sessionsPerProductiveTimeType.indices) { values[i] = - BarEntry(i.toFloat(), sessionsPerProductiveTimeType[i].toFloat() / totalTime) + BarEntry(i.toFloat(), if (totalTime == 0L) 0f else sessionsPerProductiveTimeType[i].toFloat() / totalTime) } } else if (productiveTimeType == SpinnerStatsType.NR_OF_SESSIONS) {