diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 760b60599f..1482753b72 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -373,22 +373,30 @@ public class OsmAndLocationProvider implements SensorEventListener { public void addLocationListener(@NonNull OsmAndLocationListener listener) { if (!locationListeners.contains(listener)) { - locationListeners.add(listener); + List listeners = new ArrayList<>(locationListeners); + listeners.add(listener); + locationListeners = listeners; } } public void removeLocationListener(@NonNull OsmAndLocationListener listener) { - locationListeners.remove(listener); + List listeners = new ArrayList<>(locationListeners); + listeners.remove(listener); + locationListeners = listeners; } public void addCompassListener(@NonNull OsmAndCompassListener listener) { if (!compassListeners.contains(listener)) { - compassListeners.add(listener); + List listeners = new ArrayList<>(compassListeners); + listeners.add(listener); + compassListeners = listeners; } } public void removeCompassListener(@NonNull OsmAndCompassListener listener) { - compassListeners.remove(listener); + List listeners = new ArrayList<>(compassListeners); + listeners.remove(listener); + compassListeners = listeners; } @Nullable