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