forked from upstream-mirrors/OpenTracks
Cleanup: TrackStatisticsUpdater.
This commit is contained in:
@@ -293,7 +293,7 @@ public class TrackStatisticsUpdaterTest {
|
||||
|
||||
subject.addTrackPoint(new TrackPoint(TrackPoint.Type.IDLE, Instant.ofEpochSecond(30)));
|
||||
// then
|
||||
assertTrue(subject.getSegmentStatisticUpdater().isIdle());
|
||||
assertTrue(subject.isIdle());
|
||||
assertEquals(Duration.ofSeconds(30), subject.getTrackStatistics().movingDuration());
|
||||
assertEquals(Duration.ofSeconds(30), subject.getTrackStatistics().totalDuration());
|
||||
assertEquals(Distance.of(10), subject.getTrackStatistics().totalDistance());
|
||||
@@ -303,7 +303,7 @@ public class TrackStatisticsUpdaterTest {
|
||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochSecond(40))
|
||||
.setSensorDistance(Distance.ZERO));
|
||||
// then
|
||||
assertTrue(subject.getSegmentStatisticUpdater().isIdle());
|
||||
assertTrue(subject.isIdle());
|
||||
assertEquals(Duration.ofSeconds(30), subject.getTrackStatistics().movingDuration());
|
||||
assertEquals(Duration.ofSeconds(40), subject.getTrackStatistics().totalDuration());
|
||||
assertEquals(Distance.of(10), subject.getTrackStatistics().totalDistance());
|
||||
@@ -313,7 +313,7 @@ public class TrackStatisticsUpdaterTest {
|
||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochSecond(45))
|
||||
.setSensorDistance(Distance.of(1)));
|
||||
// then
|
||||
assertTrue(subject.getSegmentStatisticUpdater().isIdle());
|
||||
assertTrue(subject.isIdle());
|
||||
assertEquals(Duration.ofSeconds(30), subject.getTrackStatistics().movingDuration());
|
||||
assertEquals(Duration.ofSeconds(45), subject.getTrackStatistics().totalDuration());
|
||||
assertEquals(Distance.of(11), subject.getTrackStatistics().totalDistance());
|
||||
@@ -323,7 +323,7 @@ public class TrackStatisticsUpdaterTest {
|
||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochSecond(50))
|
||||
.setSensorDistance(Distance.of(10)));
|
||||
// then
|
||||
assertFalse(subject.getSegmentStatisticUpdater().isIdle());
|
||||
assertFalse(subject.isIdle());
|
||||
assertEquals(Duration.ofSeconds(30), subject.getTrackStatistics().movingDuration());
|
||||
assertEquals(Duration.ofSeconds(50), subject.getTrackStatistics().totalDuration());
|
||||
assertEquals(Distance.of(21), subject.getTrackStatistics().totalDistance());
|
||||
@@ -332,7 +332,7 @@ public class TrackStatisticsUpdaterTest {
|
||||
subject.addTrackPoint(new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.ofEpochSecond(60)));
|
||||
|
||||
// then
|
||||
assertFalse(subject.getSegmentStatisticUpdater().isIdle());
|
||||
assertFalse(subject.isIdle());
|
||||
assertEquals(Duration.ofSeconds(40), subject.getTrackStatistics().movingDuration());
|
||||
assertEquals(Duration.ofSeconds(60), subject.getTrackStatistics().totalDuration());
|
||||
assertEquals(Distance.of(21), subject.getTrackStatistics().totalDistance());
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package de.dennisguse.opentracks.stats;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
@@ -79,17 +78,17 @@ public class TrackStatisticsUpdater {
|
||||
resetAverageHeartRate();
|
||||
}
|
||||
|
||||
@Deprecated //TODO Remove
|
||||
@VisibleForTesting
|
||||
public SegmentStatisticUpdater getSegmentStatisticUpdater() {
|
||||
// Take a snapshot - we don't want anyone messing with our trackStatistics
|
||||
/**
|
||||
* Compute TrackStatistics.
|
||||
*/
|
||||
public Statistics getTrackStatistics() {
|
||||
SegmentStatisticUpdater stats = new SegmentStatisticUpdater(segmentStatisticUpdater);
|
||||
stats.merge(currentSegment);
|
||||
return stats;
|
||||
return stats.getStatistics();
|
||||
}
|
||||
|
||||
public Statistics getTrackStatistics() {
|
||||
return getSegmentStatisticUpdater().getStatistics();
|
||||
public boolean isIdle() {
|
||||
return currentSegment.isIdle();
|
||||
}
|
||||
|
||||
public Statistics getCurrentSegment() {
|
||||
|
||||
Reference in New Issue
Block a user