From ccfc112e2b3e14ceb0861bbe8f062952c8869676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Wed, 12 Jul 2023 00:08:05 +0100 Subject: [PATCH] Huami: Persist workout raw details even if gpx has no points --- .../FetchSportsDetailsOperation.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsDetailsOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsDetailsOperation.java index ea8797b21..ec0b6e439 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsDetailsOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsDetailsOperation.java @@ -123,19 +123,23 @@ public class FetchSportsDetailsOperation extends AbstractFetchOperation { String fileName = FileUtils.makeValidFileName("gadgetbridge-" + trackType.toLowerCase() + "-" + DateTimeUtils.formatIso8601(summary.getStartTime()) + ".gpx"); File targetFile = new File(FileUtils.getExternalFilesDir(), fileName); + boolean exportGpxSuccess = true; try { exporter.performExport(track, targetFile); - - try (DBHandler dbHandler = GBApplication.acquireDB()) { - summary.setGpxTrack(targetFile.getAbsolutePath()); - if (rawBytesPath != null) { - summary.setRawDetailsPath(rawBytesPath); - } - dbHandler.getDaoSession().getBaseActivitySummaryDao().update(summary); - } } catch (ActivityTrackExporter.GPXTrackEmptyException ex) { + exportGpxSuccess = false; GB.toast(getContext(), "This activity does not contain GPX tracks.", Toast.LENGTH_LONG, GB.ERROR, ex); } + + try (DBHandler dbHandler = GBApplication.acquireDB()) { + if (exportGpxSuccess) { + summary.setGpxTrack(targetFile.getAbsolutePath()); + } + if (rawBytesPath != null) { + summary.setRawDetailsPath(rawBytesPath); + } + dbHandler.getDaoSession().getBaseActivitySummaryDao().update(summary); + } } catch (Exception ex) { GB.toast(getContext(), "Error getting activity details: " + ex.getMessage(), Toast.LENGTH_LONG, GB.ERROR, ex); parseSuccess = false;