mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-03 09:53:06 +02:00
Bugfix: TrackStatistics' total time was not restored correctly, when having pause/stop and then resume.
This commit is contained in:
@@ -336,9 +336,8 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
||||
|
||||
// Update database
|
||||
Track track = contentProviderUtils.getTrack(getRecordingTrackId());
|
||||
if (track != null) {
|
||||
insertTrackPoint(track, handlerServer.createSegmentStartManual());
|
||||
}
|
||||
trackStatisticsUpdater = new TrackStatisticsUpdater(track.getTrackStatistics());
|
||||
insertTrackPoint(track, handlerServer.createSegmentStartManual());
|
||||
|
||||
startRecording();
|
||||
}
|
||||
|
||||
@@ -121,6 +121,10 @@ public class TrackStatistics {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return startTime != null;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
startTime = null;
|
||||
stopTime = null;
|
||||
|
||||
@@ -116,7 +116,12 @@ public class TrackStatisticsUpdater {
|
||||
* @param minGPSDistance the min recording distance
|
||||
*/
|
||||
public void addTrackPoint(TrackPoint trackPoint, Distance minGPSDistance) {
|
||||
if (currentSegment.getStartTime() == null) {
|
||||
if (trackPoint.getType() == TrackPoint.Type.SEGMENT_START_MANUAL) {
|
||||
reset(trackPoint);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!currentSegment.isInitialized()) {
|
||||
currentSegment.setStartTime(trackPoint.getTime());
|
||||
}
|
||||
|
||||
@@ -124,11 +129,6 @@ public class TrackStatisticsUpdater {
|
||||
currentSegment.setStopTime(trackPoint.getTime());
|
||||
currentSegment.setTotalTime(Duration.between(currentSegment.getStartTime(), trackPoint.getTime()));
|
||||
|
||||
if (trackPoint.getType() == TrackPoint.Type.SEGMENT_START_MANUAL) {
|
||||
reset(trackPoint);
|
||||
return;
|
||||
}
|
||||
|
||||
// Process sensor data
|
||||
if (trackPoint.hasAltitudeGain()) {
|
||||
currentSegment.addTotalAltitudeGain(trackPoint.getAltitudeGain());
|
||||
@@ -195,7 +195,9 @@ public class TrackStatisticsUpdater {
|
||||
}
|
||||
|
||||
private void reset(TrackPoint trackPoint) {
|
||||
trackStatistics.merge(currentSegment);
|
||||
if (currentSegment.isInitialized()) {
|
||||
trackStatistics.merge(currentSegment);
|
||||
}
|
||||
currentSegment.reset(trackPoint.getTime());
|
||||
|
||||
lastTrackPoint = null;
|
||||
|
||||
Reference in New Issue
Block a user