Bugfix: GPS-based data in UI should not drop back to zero.

Likely introduced b9ed5e28e0.
This commit is contained in:
Dennis Guse
2025-03-07 07:47:01 +01:00
parent 61d0fbce08
commit ea4193a562
3 changed files with 3 additions and 13 deletions
@@ -107,7 +107,9 @@ public class TrackPointCreator implements SharedPreferences.OnSharedPreferenceCh
public Pair<TrackPoint, SensorDataSet> createCurrentTrackPoint(@Nullable TrackPoint lastTrackPointUISpeed, @Nullable TrackPoint lastTrackPointUIAltitude, @Nullable TrackPoint lastStoredTrackPointWithLocation) {
TrackPoint currentTrackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, createNow());
if (lastStoredTrackPointWithLocation != null && lastStoredTrackPointWithLocation.hasLocation()) {
SensorDataSet sensorDataSet = addSensorData(currentTrackPoint);
if (!currentTrackPoint.hasLocation() && lastStoredTrackPointWithLocation != null && lastStoredTrackPointWithLocation.hasLocation()) {
//We are taking the coordinates from the last stored TrackPoint, so the distance is monotonously increasing.
currentTrackPoint.setPosition(lastStoredTrackPointWithLocation.getPosition());
}
@@ -120,8 +122,6 @@ public class TrackPointCreator implements SharedPreferences.OnSharedPreferenceCh
currentTrackPoint.setAltitude(lastTrackPointUIAltitude.getAltitude());
}
SensorDataSet sensorDataSet = addSensorData(currentTrackPoint);
return new Pair<>(currentTrackPoint, sensorDataSet);
}