From 9088f2f379f4f2343bb96c9f4f9646e3b4404a2e Mon Sep 17 00:00:00 2001 From: aligol20 Date: Wed, 12 Jan 2022 09:50:24 +0330 Subject: [PATCH 1/3] fix crashes on getHeartRate --- .../java/com/ovalmoney/fitness/manager/Manager.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/android/src/main/java/com/ovalmoney/fitness/manager/Manager.java b/android/src/main/java/com/ovalmoney/fitness/manager/Manager.java index 6cfcd96..3511262 100644 --- a/android/src/main/java/com/ovalmoney/fitness/manager/Manager.java +++ b/android/src/main/java/com/ovalmoney/fitness/manager/Manager.java @@ -485,13 +485,14 @@ private void processCalories(DataSet dataSet, WritableArray map) { private void processHeartRate(DataSet dataSet, WritableArray map) { for (DataPoint dp : dataSet.getDataPoints()) { + heartRateMap.putString("startDate", dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS))); + heartRateMap.putString("endDate", dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS))); + heartRateMap.putDouble("quantity", dp.getValue(dp.getDataType().getFields().get(0)).asFloat()); for(Field field : dp.getDataType().getFields()) { - WritableMap heartRateMap = Arguments.createMap(); - heartRateMap.putString("startDate", dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS))); - heartRateMap.putString("endDate", dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS))); - heartRateMap.putDouble("quantity", dp.getValue(field).asFloat()); - map.pushMap(heartRateMap); - } + heartRateMap.putDouble(field.getName(), dp.getValue(field).asFloat()); + } + map.pushMap(heartRateMap); + } } From d57b35905f284f7bf3ddf1f124fbc829b4f390cf Mon Sep 17 00:00:00 2001 From: aligol20 Date: Wed, 12 Jan 2022 09:51:52 +0330 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e9b907..35dcd09 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# react-native-fitness +# react-native-fitness(fix crashes on Android by calling getHeartRate() `react-native-fitness` is a library that works on both `iOS` and `Android` with it you can interact with Apple Healthkit and Google Fit. Currently the lib provides a set of [API](#API) that you can use to read steps count or distance count for a given period of time. From 151423fd622b6b10f3f23727761aad5b90041168 Mon Sep 17 00:00:00 2001 From: aligol20 Date: Wed, 12 Jan 2022 11:47:21 +0330 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35dcd09..0aaf815 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# react-native-fitness(fix crashes on Android by calling getHeartRate() +# react-native-fitness(fix crashes on Android by calling getHeartRate()) `react-native-fitness` is a library that works on both `iOS` and `Android` with it you can interact with Apple Healthkit and Google Fit. Currently the lib provides a set of [API](#API) that you can use to read steps count or distance count for a given period of time.