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 diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java index 3512de68bc..627edb157d 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java @@ -1002,7 +1002,6 @@ public class MeasurementEditingContext implements IRouteSettingsListener { pts.add(pt); } calculatedPairs++; - params.calculationProgressCallback.updateProgress(0); List originalRoute = route.getOriginalRoute(); if (Algorithms.isEmpty(originalRoute)) { originalRoute = Collections.singletonList(RoutePlannerFrontEnd.generateStraightLineSegment( @@ -1012,6 +1011,7 @@ public class MeasurementEditingContext implements IRouteSettingsListener { application.runInUIThread(new Runnable() { @Override public void run() { + params.calculationProgressCallback.updateProgress(0); updateSegmentsForSnap(true, false); progressListener.refresh(); RouteCalculationParams params = getParams(false); diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteRecalculationHelper.java b/OsmAnd/src/net/osmand/plus/routing/RouteRecalculationHelper.java index 175003fe18..a4348e75c9 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteRecalculationHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteRecalculationHelper.java @@ -232,11 +232,17 @@ class RouteRecalculationHelper { } void startProgress(final RouteCalculationParams params) { - if (params.calculationProgressCallback != null) { - params.calculationProgressCallback.start(); - } else if (progressRoute != null) { - progressRoute.start(); - } + app.runInUIThread(new Runnable() { + + @Override + public void run() { + if (params.calculationProgressCallback != null) { + params.calculationProgressCallback.start(); + } else if (progressRoute != null) { + progressRoute.start(); + } + } + }); } void updateProgress(final RouteCalculationParams params) { diff --git a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java index 08da774f27..2b70cbe1b8 100644 --- a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java @@ -237,7 +237,12 @@ public class TransportRoutingHelper { private void startProgress(final TransportRouteCalculationParams params) { final TransportRouteCalculationProgressCallback progressRoute = this.progressRoute; if (progressRoute != null) { - progressRoute.start(); + app.runInUIThread(new Runnable() { + @Override + public void run() { + progressRoute.start(); + } + }, 300); } setCurrentRoute(-1); }