Add counter
This commit is contained in:
parent
ddcbe3bad7
commit
a6a2fc6ae3
1 changed files with 13 additions and 4 deletions
|
@ -48,9 +48,6 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
||||||
|
|
||||||
public static final String SIMULATED_PROVIDER = "OsmAnd";
|
public static final String SIMULATED_PROVIDER = "OsmAnd";
|
||||||
|
|
||||||
private static final long STALE_LOCATION_TIMEOUT = 1000 * 60 * 60; // 60 minutes
|
|
||||||
public static final long STALE_LOCATION_TIMEOUT_FOR_ICON = 1000 * 60 * 5; // 5 minutes
|
|
||||||
|
|
||||||
public interface OsmAndLocationListener {
|
public interface OsmAndLocationListener {
|
||||||
void updateLocation(net.osmand.Location location);
|
void updateLocation(net.osmand.Location location);
|
||||||
}
|
}
|
||||||
|
@ -72,6 +69,12 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
||||||
private static final int GPS_DIST_REQUEST = 0;
|
private static final int GPS_DIST_REQUEST = 0;
|
||||||
private static final int NOT_SWITCH_TO_NETWORK_WHEN_GPS_LOST_MS = 12000;
|
private static final int NOT_SWITCH_TO_NETWORK_WHEN_GPS_LOST_MS = 12000;
|
||||||
|
|
||||||
|
private static final long STALE_LOCATION_TIMEOUT = 1000 * 60 * 60; // 60 minutes
|
||||||
|
public static final long STALE_LOCATION_TIMEOUT_FOR_ICON = 1000 * 60 * 5; // 5 minutes
|
||||||
|
|
||||||
|
private static final int UPDATES_BEFORE_CHECK_LOCATION = 100;
|
||||||
|
private int updatesCounter;
|
||||||
|
|
||||||
private long lastTimeGPSLocationFixed = 0;
|
private long lastTimeGPSLocationFixed = 0;
|
||||||
private boolean gpsSignalLost;
|
private boolean gpsSignalLost;
|
||||||
private SimulationProvider simulatePosition = null;
|
private SimulationProvider simulatePosition = null;
|
||||||
|
@ -861,9 +864,15 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.osmand.Location getLastKnownLocation() {
|
public net.osmand.Location getLastKnownLocation() {
|
||||||
if (location != null && (System.currentTimeMillis() - location.getTime()) > STALE_LOCATION_TIMEOUT) {
|
if (location != null && (System.currentTimeMillis() - location.getTime()) > STALE_LOCATION_TIMEOUT &&
|
||||||
|
updatesCounter == 0) {
|
||||||
setLocation(null);
|
setLocation(null);
|
||||||
}
|
}
|
||||||
|
if (updatesCounter == UPDATES_BEFORE_CHECK_LOCATION) {
|
||||||
|
updatesCounter = 0;
|
||||||
|
} else {
|
||||||
|
updatesCounter++;
|
||||||
|
}
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue