mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-09 15:56:36 +02:00
Extract isValidHeartRate() method to HeartRateUtils
This commit is contained in:
parent
5417c5b5f6
commit
eac8f5f8c7
@ -27,4 +27,8 @@ public class HeartRateUtils {
|
|||||||
* Value is in minutes
|
* Value is in minutes
|
||||||
*/
|
*/
|
||||||
public static final int MAX_HR_MEASUREMENTS_GAP_MINUTES = 10;
|
public static final int MAX_HR_MEASUREMENTS_GAP_MINUTES = 10;
|
||||||
|
|
||||||
|
public static boolean isValidHeartRateValue(int value) {
|
||||||
|
return value > HeartRateUtils.MIN_HEART_RATE_VALUE && value < HeartRateUtils.MAX_HEART_RATE_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -486,7 +486,7 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
|||||||
colors.add(akActivity.color);
|
colors.add(akActivity.color);
|
||||||
}
|
}
|
||||||
activityEntries.add(createBarEntry(value, ts));
|
activityEntries.add(createBarEntry(value, ts));
|
||||||
if (hr && isValidHeartRateValue(sample.getHeartRate())) {
|
if (hr && HeartRateUtils.isValidHeartRateValue(sample.getHeartRate())) {
|
||||||
if (lastHrSampleIndex > -1 && ts - lastHrSampleIndex > 1800*HeartRateUtils.MAX_HR_MEASUREMENTS_GAP_MINUTES) {
|
if (lastHrSampleIndex > -1 && ts - lastHrSampleIndex > 1800*HeartRateUtils.MAX_HR_MEASUREMENTS_GAP_MINUTES) {
|
||||||
heartrateEntries.add(createLineEntry(0, lastHrSampleIndex + 1));
|
heartrateEntries.add(createLineEntry(0, lastHrSampleIndex + 1));
|
||||||
heartrateEntries.add(createLineEntry(0, ts - 1));
|
heartrateEntries.add(createLineEntry(0, ts - 1));
|
||||||
@ -550,10 +550,6 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
|||||||
return new DefaultChartsData(combinedData, xValueFormatter);
|
return new DefaultChartsData(combinedData, xValueFormatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isValidHeartRateValue(int value) {
|
|
||||||
return value > HeartRateUtils.MIN_HEART_RATE_VALUE && value < HeartRateUtils.MAX_HEART_RATE_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement this to supply the samples to be displayed.
|
* Implement this to supply the samples to be displayed.
|
||||||
*
|
*
|
||||||
|
@ -168,7 +168,7 @@ public class LiveActivityFragment extends AbstractChartFragment {
|
|||||||
private void addSample(ActivitySample sample) {
|
private void addSample(ActivitySample sample) {
|
||||||
int heartRate = sample.getHeartRate();
|
int heartRate = sample.getHeartRate();
|
||||||
int timestamp = tsTranslation.shorten(sample.getTimestamp());
|
int timestamp = tsTranslation.shorten(sample.getTimestamp());
|
||||||
if (isValidHeartRateValue(heartRate)) {
|
if (HeartRateUtils.isValidHeartRateValue(heartRate)) {
|
||||||
setCurrentHeartRate(heartRate, timestamp);
|
setCurrentHeartRate(heartRate, timestamp);
|
||||||
}
|
}
|
||||||
int steps = sample.getSteps();
|
int steps = sample.getSteps();
|
||||||
|
Loading…
Reference in New Issue
Block a user