Fix #4017
This commit is contained in:
parent
40faa8a9c3
commit
45629ef87d
3 changed files with 13 additions and 4 deletions
|
@ -48,6 +48,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
|
||||
public static final String SIMULATED_PROVIDER = "OsmAnd";
|
||||
|
||||
public static final long LOCATION_SHELF_LIFE = 1000 * 60 * 60; // 60 minutes
|
||||
|
||||
public interface OsmAndLocationListener {
|
||||
void updateLocation(net.osmand.Location location);
|
||||
|
|
|
@ -113,7 +113,7 @@ public class MapInfoWidgetsFactory {
|
|||
}
|
||||
|
||||
public TextInfoWidget createRulerControl(final MapActivity map) {
|
||||
final String title = "-";
|
||||
final String title = "—";
|
||||
final TextInfoWidget rulerControl = new TextInfoWidget(map) {
|
||||
RulerControlLayer rulerLayer = map.getMapLayers().getRulerControlLayer();
|
||||
LatLon cacheFirstTouchPoint = new LatLon(0, 0);
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.plus.IconsCache;
|
|||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
|
@ -55,7 +56,7 @@ public class MapMarkersWidgetsFactory {
|
|||
private ImageButton moreButton2nd;
|
||||
|
||||
private LatLon loc;
|
||||
private LatLon lastKnownPosition;
|
||||
private Location lastKnownPosition;
|
||||
|
||||
public MapMarkersWidgetsFactory(final MapActivity map) {
|
||||
this.map = map;
|
||||
|
@ -189,9 +190,16 @@ public class MapMarkersWidgetsFactory {
|
|||
Location l = map.getMapViewTrackingUtilities().getMyLocation();
|
||||
if (l != null) {
|
||||
loc = new LatLon(l.getLatitude(), l.getLongitude());
|
||||
lastKnownPosition = loc;
|
||||
lastKnownPosition = l;
|
||||
} else if (lastKnownPosition == null) {
|
||||
loc = null;
|
||||
} else {
|
||||
loc = lastKnownPosition;
|
||||
if (System.currentTimeMillis() - lastKnownPosition.getTime() < OsmAndLocationProvider.LOCATION_SHELF_LIFE) {
|
||||
loc = new LatLon(lastKnownPosition.getLatitude(), lastKnownPosition.getLongitude());
|
||||
} else {
|
||||
loc = null;
|
||||
lastKnownPosition = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue