mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 10:35:50 +01:00
Show separate curves when the time between two measurements is too long #273
This commit is contained in:
parent
f52126ed36
commit
e87a357bed
@ -3,4 +3,12 @@ package nodomain.freeyourgadget.gadgetbridge.activities;
|
|||||||
public class HeartRateUtils {
|
public class HeartRateUtils {
|
||||||
public static final int MAX_HEART_RATE_VALUE = 250;
|
public static final int MAX_HEART_RATE_VALUE = 250;
|
||||||
public static final int MIN_HEART_RATE_VALUE = 0;
|
public static final int MIN_HEART_RATE_VALUE = 0;
|
||||||
|
/**
|
||||||
|
* The maxiumum gap between two hr measurements in which
|
||||||
|
* we interpolate between the measurements. Otherwise, two
|
||||||
|
* distinct measurements will be shown.
|
||||||
|
*
|
||||||
|
* Value is in minutes
|
||||||
|
*/
|
||||||
|
public static final int MAX_HR_MEASUREMENTS_GAP_MINUTES = 10;
|
||||||
}
|
}
|
||||||
|
@ -421,6 +421,7 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
|||||||
boolean hr = supportsHeartrate();
|
boolean hr = supportsHeartrate();
|
||||||
List<Entry> heartrateEntries = hr ? new ArrayList<Entry>(numEntries) : null;
|
List<Entry> heartrateEntries = hr ? new ArrayList<Entry>(numEntries) : null;
|
||||||
List<Integer> colors = new ArrayList<>(numEntries); // this is kinda inefficient...
|
List<Integer> colors = new ArrayList<>(numEntries); // this is kinda inefficient...
|
||||||
|
int lastHrSampleIndex = -1;
|
||||||
|
|
||||||
for (int i = 0; i < numEntries; i++) {
|
for (int i = 0; i < numEntries; i++) {
|
||||||
ActivitySample sample = samples.get(i);
|
ActivitySample sample = samples.get(i);
|
||||||
@ -463,7 +464,13 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
|||||||
}
|
}
|
||||||
activityEntries.add(createBarEntry(value, i));
|
activityEntries.add(createBarEntry(value, i));
|
||||||
if (hr && isValidHeartRateValue(sample.getCustomValue())) {
|
if (hr && isValidHeartRateValue(sample.getCustomValue())) {
|
||||||
|
if (lastHrSampleIndex > -1 && i - lastHrSampleIndex > HeartRateUtils.MAX_HR_MEASUREMENTS_GAP_MINUTES) {
|
||||||
|
heartrateEntries.add(createLineEntry(0, lastHrSampleIndex + 1));
|
||||||
|
heartrateEntries.add(createLineEntry(0, i - 1));
|
||||||
|
}
|
||||||
|
|
||||||
heartrateEntries.add(createLineEntry(sample.getCustomValue(), i));
|
heartrateEntries.add(createLineEntry(sample.getCustomValue(), i));
|
||||||
|
lastHrSampleIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
String xLabel = "";
|
String xLabel = "";
|
||||||
|
Loading…
Reference in New Issue
Block a user