Introduced Statistics as a value object.

This commit is contained in:
Dennis Guse
2025-10-26 20:23:39 +01:00
parent fba08fe8dd
commit 920ad5129a
8 changed files with 105 additions and 29 deletions
@@ -6,11 +6,13 @@ import de.dennisguse.opentracks.data.models.Track;
import de.dennisguse.opentracks.data.models.TrackPoint;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataSet;
import de.dennisguse.opentracks.stats.SegmentStatisticUpdater;
import de.dennisguse.opentracks.stats.Statistics;
/**
* {@link Track} and {@link TrackPoint} must be immutable (i.e., their content does not change).
*/
public record RecordingData(Track track, TrackPoint latestTrackPoint, SensorDataSet sensorDataSet, SegmentStatisticUpdater currentSegment) {
public record RecordingData(Track track, TrackPoint latestTrackPoint, SensorDataSet sensorDataSet,
Statistics currentSegment) {
public String getTrackCategory() {
if (track == null) {
return "";
@@ -26,14 +28,4 @@ public record RecordingData(Track track, TrackPoint latestTrackPoint, SensorData
return track.getTrackStatistics();
}
@NonNull
public SegmentStatisticUpdater getStatisticsCurrentSegment() {
if (currentSegment == null) {
return new SegmentStatisticUpdater();
}
return currentSegment;
}
}
@@ -131,9 +131,8 @@ public class TrackRecordingManager implements SharedPreferences.OnSharedPreferen
}
track.setTrackStatistics(tmpTrackStatisticsUpdater.getTrackStatistics());
SegmentStatisticUpdater currentSegment = tmpTrackStatisticsUpdater.getCurrentSegment();
return new RecordingData(track, current.first, current.second, currentSegment);
return new RecordingData(track, current.first, current.second, tmpTrackStatisticsUpdater.getCurrentSegment());
}
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)