From 063fb31931b4b7b3a9906655caa97f1401c0f51f Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Fri, 4 Aug 2023 17:57:46 +0200 Subject: [PATCH] Garmin VivoMoveHR: prevent app crash Use a more robust cast approach to prevent application crashes in some corner cases (e.g. when writing Math.round()ed values) Since I don't own a VivoMoveHR device I couldn't test for regressions on the watch. --- .../service/devices/vivomovehr/fit/FitMessage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/vivomovehr/fit/FitMessage.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/vivomovehr/fit/FitMessage.java index b37c93514..8604020a6 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/vivomovehr/fit/FitMessage.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/vivomovehr/fit/FitMessage.java @@ -100,12 +100,12 @@ public class FitMessage { case UINT16Z: case UINT32Z: case BYTE: - writeFitNumberToMessage(writer, (Integer) value, size); + writeFitNumberToMessage(writer, ((Number) value).intValue(), size); break; case SINT64: case UINT64: case UINT64Z: - writeFitNumberToMessage(writer, (Long) value, size); + writeFitNumberToMessage(writer, ((Number) value).longValue(), size); break; case STRING: writeFitStringToMessage(writer, (String) value, size);