forked from upstream-mirrors/OpenTracks
Move temp functionality into TrackStatisticsUpdater.
This commit is contained in:
+26
-5
@@ -301,15 +301,36 @@ public class TrackStatisticsUpdaterTest {
|
|||||||
tp4.setSpeed(Speed.of(5f));
|
tp4.setSpeed(Speed.of(5f));
|
||||||
TrackPoint tp5 = new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.ofEpochMilli(5000));
|
TrackPoint tp5 = new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.ofEpochMilli(5000));
|
||||||
|
|
||||||
TrackStatisticsUpdater subject = new TrackStatisticsUpdater(List.of(tp1, tp2,tp3, tp4));
|
TrackStatisticsUpdater initial = new TrackStatisticsUpdater(List.of(tp1, tp2,tp3, tp4));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
TrackStatisticsUpdater copy = new TrackStatisticsUpdater(subject);
|
TrackStatisticsUpdater subject = new TrackStatisticsUpdater(initial, tp5);
|
||||||
subject.addTrackPoint(tp5);
|
|
||||||
copy.addTrackPoint(tp5);
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(Distance.of(55.28713929653168), subject.getTrackStatistics().totalDistance());
|
assertEquals(new Statistics(
|
||||||
|
Instant.ofEpochMilli(1000),
|
||||||
|
Instant.ofEpochMilli(4000),
|
||||||
|
Duration.ofSeconds(3),
|
||||||
|
Duration.ofSeconds(3),
|
||||||
|
Distance.of(55.28713929653168),
|
||||||
|
Speed.of(18.429046432177227),
|
||||||
|
new AltitudeExtremities(5, 5),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
), initial.getTrackStatistics());
|
||||||
|
assertEquals(new Statistics(
|
||||||
|
Instant.ofEpochMilli(1000),
|
||||||
|
Instant.ofEpochMilli(5000),
|
||||||
|
Duration.ofSeconds(4),
|
||||||
|
Duration.ofSeconds(4),
|
||||||
|
Distance.of(55.28713929653168),
|
||||||
|
Speed.of(18.429046432177227),
|
||||||
|
new AltitudeExtremities(5, 5),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
), subject.getTrackStatistics());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TrackPoint createTrackPoint(double latitude, double longitude, Altitude altitude, Instant time) {
|
public TrackPoint createTrackPoint(double latitude, double longitude, Altitude altitude, Instant time) {
|
||||||
|
|||||||
@@ -116,10 +116,9 @@ public class TrackRecordingManager implements SharedPreferences.OnSharedPreferen
|
|||||||
}
|
}
|
||||||
|
|
||||||
RecordingData getDataForUI() {
|
RecordingData getDataForUI() {
|
||||||
TrackStatisticsUpdater tmpTrackStatisticsUpdater = new TrackStatisticsUpdater(trackStatisticsUpdater);
|
|
||||||
Pair<TrackPoint, SensorDataSet> current = trackPointCreator.createCurrentTrackPoint(lastTrackPointUIWithSpeed, lastTrackPointUIWithAltitude, lastStoredTrackPointWithLocation);
|
Pair<TrackPoint, SensorDataSet> current = trackPointCreator.createCurrentTrackPoint(lastTrackPointUIWithSpeed, lastTrackPointUIWithAltitude, lastStoredTrackPointWithLocation);
|
||||||
|
|
||||||
tmpTrackStatisticsUpdater.addTrackPoint(current.first);
|
TrackStatisticsUpdater tmpTrackStatisticsUpdater = new TrackStatisticsUpdater(trackStatisticsUpdater, current.first);
|
||||||
|
|
||||||
ALTITUDE_CORRECTION_MANAGER.correctAltitude(context, current.first);
|
ALTITUDE_CORRECTION_MANAGER.correctAltitude(context, current.first);
|
||||||
|
|
||||||
|
|||||||
@@ -72,13 +72,14 @@ public class TrackStatisticsUpdater {
|
|||||||
resetAverageHeartRate();
|
resetAverageHeartRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public TrackStatisticsUpdater(@NonNull TrackStatisticsUpdater toCopy, TrackPoint tmp) {
|
||||||
public TrackStatisticsUpdater(@NonNull TrackStatisticsUpdater toCopy) {
|
|
||||||
this.currentSegment = new SegmentStatisticUpdater(toCopy.currentSegment);
|
|
||||||
this.statisticsWithoutCurrentSegment = toCopy.statisticsWithoutCurrentSegment;
|
this.statisticsWithoutCurrentSegment = toCopy.statisticsWithoutCurrentSegment;
|
||||||
|
this.currentSegment = new SegmentStatisticUpdater(toCopy.currentSegment);
|
||||||
|
|
||||||
this.lastTrackPoint = toCopy.lastTrackPoint;
|
this.lastTrackPoint = toCopy.lastTrackPoint;
|
||||||
resetAverageHeartRate();
|
resetAverageHeartRate();
|
||||||
|
|
||||||
|
addTrackPoint(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user