diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 3bd73c406f..b083ae0b2d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -85,6 +85,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL private LatLon myLocation; private Float heading; private boolean inLocationUpdate = false; + private boolean useCachedLocation; private boolean appModeChanged; private boolean appModeListenerAdded; private boolean autoHide; @@ -1215,14 +1216,26 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL return myLocation; } + public boolean isUseCachedLocation() { + return useCachedLocation; + } + public Float getHeading() { return heading; } public void updateMyLocation(net.osmand.Location location) { - if (location != null && active && displayDistanceDirection()) { - myLocation = new LatLon(location.getLatitude(), location.getLongitude()); - updateLocation(false, true, false); + if (active && displayDistanceDirection()) { + if (location == null) { + location = getMapActivity().getMyApplication().getLocationProvider().getLastStaleKnownLocation(); + useCachedLocation = location != null; + } else { + useCachedLocation = false; + } + if (location != null) { + myLocation = new LatLon(location.getLatitude(), location.getLongitude()); + updateLocation(false, true, false); + } } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 656a6b2c1f..77d19ab706 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -1238,8 +1238,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo TextView distanceText = (TextView) view.findViewById(R.id.distance); ImageView direction = (ImageView) view.findViewById(R.id.direction); float myHeading = menu.getHeading() == null ? 0f : menu.getHeading(); - DashLocationFragment.updateLocationView(false, menu.getMyLocation(), myHeading, direction, distanceText, - menu.getLatLon().getLatitude(), menu.getLatLon().getLongitude(), screenOrientation, app, activity); + int color = menu.isUseCachedLocation() ? R.color.icon_color : 0; + DashLocationFragment.updateLocationView(false, menu.getMyLocation(), myHeading, direction, color, distanceText, + color, menu.getLatLon().getLatitude(), menu.getLatLon().getLongitude(), screenOrientation, app, activity); } }