This commit is contained in:
Alexander Sytnyk 2017-07-20 13:41:31 +03:00
parent 40faa8a9c3
commit 45629ef87d
3 changed files with 13 additions and 4 deletions

View file

@ -48,6 +48,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
public static final String SIMULATED_PROVIDER = "OsmAnd"; public static final String SIMULATED_PROVIDER = "OsmAnd";
public static final long LOCATION_SHELF_LIFE = 1000 * 60 * 60; // 60 minutes
public interface OsmAndLocationListener { public interface OsmAndLocationListener {
void updateLocation(net.osmand.Location location); void updateLocation(net.osmand.Location location);

View file

@ -113,7 +113,7 @@ public class MapInfoWidgetsFactory {
} }
public TextInfoWidget createRulerControl(final MapActivity map) { public TextInfoWidget createRulerControl(final MapActivity map) {
final String title = "-"; final String title = "";
final TextInfoWidget rulerControl = new TextInfoWidget(map) { final TextInfoWidget rulerControl = new TextInfoWidget(map) {
RulerControlLayer rulerLayer = map.getMapLayers().getRulerControlLayer(); RulerControlLayer rulerLayer = map.getMapLayers().getRulerControlLayer();
LatLon cacheFirstTouchPoint = new LatLon(0, 0); LatLon cacheFirstTouchPoint = new LatLon(0, 0);

View file

@ -12,6 +12,7 @@ import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashLocationFragment; import net.osmand.plus.dashboard.DashLocationFragment;
@ -55,7 +56,7 @@ public class MapMarkersWidgetsFactory {
private ImageButton moreButton2nd; private ImageButton moreButton2nd;
private LatLon loc; private LatLon loc;
private LatLon lastKnownPosition; private Location lastKnownPosition;
public MapMarkersWidgetsFactory(final MapActivity map) { public MapMarkersWidgetsFactory(final MapActivity map) {
this.map = map; this.map = map;
@ -189,9 +190,16 @@ public class MapMarkersWidgetsFactory {
Location l = map.getMapViewTrackingUtilities().getMyLocation(); Location l = map.getMapViewTrackingUtilities().getMyLocation();
if (l != null) { if (l != null) {
loc = new LatLon(l.getLatitude(), l.getLongitude()); loc = new LatLon(l.getLatitude(), l.getLongitude());
lastKnownPosition = loc; lastKnownPosition = l;
} else if (lastKnownPosition == null) {
loc = null;
} else { } else {
loc = lastKnownPosition; if (System.currentTimeMillis() - lastKnownPosition.getTime() < OsmAndLocationProvider.LOCATION_SHELF_LIFE) {
loc = new LatLon(lastKnownPosition.getLatitude(), lastKnownPosition.getLongitude());
} else {
loc = null;
lastKnownPosition = null;
}
} }
} }