mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-03 09:53:06 +02:00
Try to fix moving time.
This commit is contained in:
@@ -513,6 +513,7 @@ public class TrackRecordingService extends Service implements LocationListener {
|
||||
|
||||
// Update the idle time if needed.
|
||||
locationListenerPolicy.updateIdleTime(statsBuilder.getIdleTime());
|
||||
addLocationToStats(location);
|
||||
if (currentRecordingInterval !=
|
||||
locationListenerPolicy.getDesiredPollingInterval()) {
|
||||
registerLocationListener();
|
||||
@@ -538,8 +539,6 @@ public class TrackRecordingService extends Service implements LocationListener {
|
||||
// two and ignore the rest. This code will only have an effect if the
|
||||
// maxRecordingDistance = 0
|
||||
if (distanceToLast == 0 && !hasSensorData) {
|
||||
addLocationToStats(location);
|
||||
|
||||
if (isMoving) {
|
||||
Log.d(MyTracksConstants.TAG, "Found two identical locations.");
|
||||
isMoving = false;
|
||||
@@ -561,7 +560,6 @@ public class TrackRecordingService extends Service implements LocationListener {
|
||||
}
|
||||
} else if (distanceToLastRecorded > minRecordingDistance
|
||||
|| hasSensorData) {
|
||||
addLocationToStats(location);
|
||||
if (lastLocation != null && !isMoving) {
|
||||
// Last location was the last stationary location. Need to go back and
|
||||
// add it.
|
||||
@@ -1197,6 +1195,8 @@ public class TrackRecordingService extends Service implements LocationListener {
|
||||
|
||||
public void setMinRecordingDistance(int minRecordingDistance) {
|
||||
this.minRecordingDistance = minRecordingDistance;
|
||||
this.statsBuilder.setMinRecordingDistance(minRecordingDistance);
|
||||
this.waypointStatsBuilder.setMinRecordingDistance(minRecordingDistance);
|
||||
}
|
||||
|
||||
public int getMinRequiredAccuracy() {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.google.android.apps.mytracks.stats;
|
||||
|
||||
import com.google.android.apps.mytracks.MyTracksConstants;
|
||||
import com.google.android.apps.mytracks.MyTracksSettings;
|
||||
|
||||
import android.location.Location;
|
||||
import android.util.Log;
|
||||
@@ -89,6 +90,9 @@ public class TripStatisticsBuilder {
|
||||
*/
|
||||
private long totalLocations = 0;
|
||||
|
||||
private int minRecordingDistance =
|
||||
MyTracksSettings.DEFAULT_MIN_RECORDING_DISTANCE;
|
||||
|
||||
/**
|
||||
* Creates a new trip starting at the given time.
|
||||
*
|
||||
@@ -146,7 +150,7 @@ public class TripStatisticsBuilder {
|
||||
|
||||
// Don't do anything if we didn't move since last fix:
|
||||
double distance = lastLocation.distanceTo(currentLocation);
|
||||
if (distance < MyTracksConstants.MAX_NO_MOVEMENT_DISTANCE &&
|
||||
if (distance < minRecordingDistance &&
|
||||
currentSpeed < MyTracksConstants.MAX_NO_MOVEMENT_SPEED) {
|
||||
lastLocation = currentLocation;
|
||||
return false;
|
||||
@@ -359,4 +363,8 @@ public class TripStatisticsBuilder {
|
||||
// Take a snapshot - we don't want anyone messing with our internals
|
||||
return new TripStatistics(data);
|
||||
}
|
||||
|
||||
public void setMinRecordingDistance(int minRecordingDistance) {
|
||||
this.minRecordingDistance = minRecordingDistance;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user