diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index f0dff0fb77..d07a2b40d4 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -499,8 +499,8 @@ public class OsmAndLocationProvider implements SensorEventListener { } private float calcGeoMagneticCorrection(float val) { - if (previousCorrectionValue == 360 && getLastKnownLocation() != null) { - net.osmand.Location l = getLastKnownLocation(); + net.osmand.Location l = getLastKnownLocation(); + if (previousCorrectionValue == 360 && l != null) { GeomagneticField gf = new GeomagneticField((float) l.getLatitude(), (float) l.getLongitude(), (float) l.getAltitude(), System.currentTimeMillis()); previousCorrectionValue = gf.getDeclination(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index dd929cfc93..31c250c646 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -980,8 +980,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { if (app != null && view != null) { View compassView = view.findViewById(R.id.compass_layout); Location ll = app.getLocationProvider().getLastKnownLocation(); - boolean gpsFixed = ll != null && System.currentTimeMillis() - ll.getTime() < 1000 * 60 * 60 * 20; - if (gpsFixed && menu.displayDistanceDirection() && menu.getCurrentMenuState() != MenuState.FULL_SCREEN) { + if (ll != null && menu.displayDistanceDirection() && menu.getCurrentMenuState() != MenuState.FULL_SCREEN) { updateDistanceDirection(); compassView.setVisibility(View.VISIBLE); } else { diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index a0cfbf5d3a..f9d5b323cb 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -27,6 +27,7 @@ import android.widget.SeekBar; import android.widget.TextView; import net.osmand.AndroidUtils; +import net.osmand.Location; import net.osmand.core.android.MapRendererContext; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; @@ -794,8 +795,8 @@ public class MapControlsLayer extends OsmandMapLayer { } private void updateMyLocation(RoutingHelper rh, boolean dialogOpened) { - boolean enabled = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() != null && - !isLocationOutdated(mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation()); + Location lastKnownLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation(); + boolean enabled = lastKnownLocation != null && !isLocationOutdated(lastKnownLocation); boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation(); if (!enabled) { diff --git a/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java b/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java index 27487d8d24..f66c05713f 100644 --- a/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java @@ -86,9 +86,9 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay } // draw boolean nm = nightMode != null && nightMode.isNightMode(); - updateIcons(view.getSettings().getApplicationMode(), nm, - isLocationOutdated(locationProvider.getLastKnownLocation())); Location lastKnownLocation = locationProvider.getLastKnownLocation(); + updateIcons(view.getSettings().getApplicationMode(), nm, + isLocationOutdated(lastKnownLocation)); if(lastKnownLocation == null || view == null){ return; } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 9109cab768..f77dff5a9d 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -718,18 +718,20 @@ public class MapInfoWidgetsFactory { settings.SHOW_STREET_NAME.get()) { RouteDataObject rt = locationProvider.getLastKnownRouteSegment(); if (rt != null) { + Location lastKnownLocation = locationProvider.getLastKnownLocation(); text = RoutingHelper.formatStreetName( rt.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()), - rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())), - rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())), + rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)), + rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)), "ยป"); } if (text == null) { text = ""; } else { - if(!Algorithms.isEmpty(text) && locationProvider.getLastKnownLocation() != null) { + Location lastKnownLocation = locationProvider.getLastKnownLocation(); + if(!Algorithms.isEmpty(text) && lastKnownLocation != null) { double dist = - CurrentPositionHelper.getOrthogonalDistance(rt, locationProvider.getLastKnownLocation()); + CurrentPositionHelper.getOrthogonalDistance(rt, lastKnownLocation); if(dist < 50) { showMarker = true; } else {