From 86888ec52b3a2b8879910847ad667bb14e24f9fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Mon, 30 Sep 2024 21:19:00 +0100 Subject: [PATCH] Fix crash on unknown values --- .../activities/workouts/WorkoutValueFormatter.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/workouts/WorkoutValueFormatter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/workouts/WorkoutValueFormatter.java index 9e88ddc94..9857b6cee 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/workouts/WorkoutValueFormatter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/workouts/WorkoutValueFormatter.java @@ -40,6 +40,10 @@ public class WorkoutValueFormatter { } public String formatValue(final Object rawValue, String unit) { + if (rawValue == null) { + return GBApplication.getContext().getString(R.string.stats_empty_value); + } + if (ActivitySummaryEntries.UNIT_RAW_STRING.equals(unit)) { return String.valueOf(rawValue); } @@ -54,6 +58,10 @@ public class WorkoutValueFormatter { } } + if (!(rawValue instanceof Number)) { + return String.valueOf(rawValue); + } + double value = ((Number) rawValue).doubleValue(); if (!show_raw_data) {