forked from upstream-mirrors/OpenTracks
Move isIdle to TrackStatisticsUpdater.
This commit is contained in:
@@ -67,8 +67,6 @@ public class SegmentStatisticUpdater {
|
||||
private HeartRate avgHeartRate = null;
|
||||
private Power avgPower = null;
|
||||
|
||||
private boolean isIdle;
|
||||
|
||||
public SegmentStatisticUpdater() {
|
||||
reset();
|
||||
}
|
||||
@@ -80,7 +78,6 @@ public class SegmentStatisticUpdater {
|
||||
*/
|
||||
public SegmentStatisticUpdater(SegmentStatisticUpdater other) {
|
||||
this(other.getStatistics());
|
||||
this.isIdle = other.isIdle();
|
||||
}
|
||||
|
||||
public SegmentStatisticUpdater(Statistics statistics) {
|
||||
@@ -120,8 +117,6 @@ public class SegmentStatisticUpdater {
|
||||
stopTime = stopTime.isAfter(other.stopTime) ? stopTime : other.stopTime;
|
||||
}
|
||||
|
||||
isIdle = other.isIdle; //TODO This implicitly assumes append mode.
|
||||
|
||||
if (avgHeartRate == null) {
|
||||
avgHeartRate = other.avgHeartRate;
|
||||
} else {
|
||||
@@ -190,8 +185,6 @@ public class SegmentStatisticUpdater {
|
||||
maxSpeed = Speed.ZERO;
|
||||
totalAltitudeGain_m = null;
|
||||
totalAltitudeLoss_m = null;
|
||||
|
||||
isIdle = false;
|
||||
}
|
||||
|
||||
public void reset(Instant startTime) {
|
||||
@@ -256,14 +249,6 @@ public class SegmentStatisticUpdater {
|
||||
this.movingDuration = this.movingDuration.plus(movingDuration);
|
||||
}
|
||||
|
||||
public boolean isIdle() {
|
||||
return isIdle;
|
||||
}
|
||||
|
||||
public void setIdle(boolean idle) {
|
||||
isIdle = idle;
|
||||
}
|
||||
|
||||
private Speed getAverageMovingSpeed() {
|
||||
return Speed.of(totalDistance, movingDuration);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ public class TrackStatisticsUpdater {
|
||||
// Current segment's last trackPoint
|
||||
private TrackPoint lastTrackPoint;
|
||||
|
||||
private boolean isIdle;
|
||||
|
||||
public TrackStatisticsUpdater() {
|
||||
this(new SegmentStatisticUpdater());
|
||||
}
|
||||
@@ -88,7 +90,7 @@ public class TrackStatisticsUpdater {
|
||||
}
|
||||
|
||||
public boolean isIdle() {
|
||||
return currentSegment.isIdle();
|
||||
return isIdle;
|
||||
}
|
||||
|
||||
public Statistics getCurrentSegment() {
|
||||
@@ -159,19 +161,19 @@ public class TrackStatisticsUpdater {
|
||||
currentSegment.addTotalDistance(movingDistance);
|
||||
}
|
||||
|
||||
if (!currentSegment.isIdle()) {
|
||||
if (!isIdle) {
|
||||
if (!trackPoint.isSegmentManualStart() && lastTrackPoint != null) {
|
||||
currentSegment.addMovingTime(trackPoint, lastTrackPoint);
|
||||
}
|
||||
}
|
||||
|
||||
if (trackPoint.isIdleTriggered()) {
|
||||
currentSegment.setIdle(true);
|
||||
} else if (currentSegment.isIdle()) {
|
||||
isIdle = true;
|
||||
} else if (isIdle) {
|
||||
// Shall we switch to non-idle?
|
||||
if (movingDistance != null
|
||||
&& movingDistance.greaterOrEqualThan(PreferencesUtils.getRecordingDistanceInterval())) {
|
||||
currentSegment.setIdle(false);
|
||||
isIdle = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user