diff --git a/OsmAnd-java/src/main/java/net/osmand/util/MapUtils.java b/OsmAnd-java/src/main/java/net/osmand/util/MapUtils.java index dffbd72ad5..bbd9db4fcd 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/MapUtils.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/MapUtils.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; +import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.data.MapObject; import net.osmand.data.QuadPoint; @@ -616,6 +617,12 @@ public class MapUtils { r.bottom = Math.min(r.bottom, latitude); } } + + public static boolean areLatLonEqual(Location l1, Location l2) { + return l1 == null && l2 == null + || (l1 != null && l2 != null && Math.abs(l1.getLatitude() - l2.getLatitude()) < 0.00001 + && Math.abs(l1.getLongitude() - l2.getLongitude()) < 0.00001); + } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java index 3ba926d0d3..7adaa6b39b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java @@ -49,6 +49,7 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag private boolean locationUpdateStarted; private boolean compassUpdateAllowed = true; private PointType pointType; + private Location location; private float lastHeading; private FavoritesListener favoritesListener; @@ -213,7 +214,10 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag @Override public void updateLocation(Location location) { - updateLocationUi(); + if (!MapUtils.areLatLonEqual(this.location, location)) { + this.location = location; + updateLocationUi(); + } } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index d46cc257fe..acaceda8a7 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -1413,11 +1413,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm @Override public void updateLocation(Location location) { - boolean newLocation = this.location == null && location != null; - boolean locationChanged = this.location != null && location != null - && this.location.getLatitude() != location.getLatitude() - && this.location.getLongitude() != location.getLongitude(); - if (newLocation || locationChanged) { + if (!MapUtils.areLatLonEqual(this.location, location)) { this.location = location; updateLocationUi(); } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java index 2d48ad501e..b537172683 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java @@ -160,11 +160,7 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL @Override public void updateLocation(Location location) { - boolean newLocation = this.location == null && location != null; - boolean locationChanged = this.location != null && location != null - && this.location.getLatitude() != location.getLatitude() - && this.location.getLongitude() != location.getLongitude(); - if (newLocation || locationChanged) { + if (!MapUtils.areLatLonEqual(this.location, location)) { this.location = location; updateLocationUi(); } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java index 549f9385c0..e6f6b9d827 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java @@ -441,11 +441,7 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL @Override public void updateLocation(Location location) { - boolean newLocation = this.location == null && location != null; - boolean locationChanged = this.location != null && location != null - && this.location.getLatitude() != location.getLatitude() - && this.location.getLongitude() != location.getLongitude(); - if (newLocation || locationChanged) { + if (!MapUtils.areLatLonEqual(this.location, location)) { this.location = location; updateLocationUi(); }