diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryJsonSummary.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryJsonSummary.java index 0b713adf6..4b8f6983e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryJsonSummary.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryJsonSummary.java @@ -12,7 +12,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiActivitySummaryParser; import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary; public class ActivitySummaryJsonSummary { @@ -73,7 +72,11 @@ public class ActivitySummaryJsonSummary { private String getCorrectSummary(BaseActivitySummary item){ if (item.getRawSummaryData() != null) { - item = summaryParser.parseBinaryData(item); + try { + item = summaryParser.parseBinaryData(item); + } catch (final Exception e) { + LOG.error("Failed to re-parse corrected summary", e); + } } return item.getSummaryData(); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsSummaryOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsSummaryOperation.java index b22f01dce..54a25fa8f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsSummaryOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsSummaryOperation.java @@ -93,7 +93,14 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation { summary = new BaseActivitySummary(); summary.setStartTime(getLastStartTimestamp().getTime()); // due to a bug this has to be set summary.setRawSummaryData(buffer.toByteArray()); - summary = summaryParser.parseBinaryData(summary); + try { + summary = summaryParser.parseBinaryData(summary); + } catch (final Exception e) { + GB.toast(getContext(), "Failed to parse activity summary", Toast.LENGTH_LONG, GB.ERROR, e); + summary = null; + parseSummarySuccess = false; + } + if (summary != null) { summary.setSummaryData(null); // remove json before saving to database, try (DBHandler dbHandler = GBApplication.acquireDB()) {