[android] clear previous style loaded listener when setting a new style
This commit is contained in:
committed by
Łukasz Paczos
parent
98d3f42e18
commit
03159b3589
@@ -63,7 +63,10 @@ public final class MapboxMap {
|
||||
private final Transform transform;
|
||||
private final CameraChangeDispatcher cameraChangeDispatcher;
|
||||
private final OnGesturesManagerInteractionListener onGesturesManagerInteractionListener;
|
||||
private final List<Style.OnStyleLoaded> styleLoadedCallbacks = new ArrayList<>();
|
||||
private final List<Style.OnStyleLoaded> awaitingStyleGetters = new ArrayList<>();
|
||||
|
||||
@Nullable
|
||||
private Style.OnStyleLoaded styleLoadedCallback;
|
||||
|
||||
private LocationComponent locationComponent;
|
||||
private AnnotationManager annotationManager;
|
||||
@@ -103,7 +106,7 @@ public final class MapboxMap {
|
||||
if (style != null && style.isFullyLoaded()) {
|
||||
onStyleLoaded.onStyleLoaded(style);
|
||||
} else {
|
||||
styleLoadedCallbacks.add(onStyleLoaded);
|
||||
awaitingStyleGetters.add(onStyleLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +213,7 @@ public final class MapboxMap {
|
||||
* Called when the map failed loading a style.
|
||||
*/
|
||||
void onFailLoadingStyle() {
|
||||
styleLoadedCallbacks.clear();
|
||||
styleLoadedCallback = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -814,15 +817,12 @@ public final class MapboxMap {
|
||||
* @see Style
|
||||
*/
|
||||
public void setStyle(Style.Builder builder, final Style.OnStyleLoaded callback) {
|
||||
styleLoadedCallback = callback;
|
||||
locationComponent.onStartLoadingMap();
|
||||
if (style != null) {
|
||||
style.clear();
|
||||
}
|
||||
|
||||
if (callback != null) {
|
||||
styleLoadedCallbacks.add(callback);
|
||||
}
|
||||
|
||||
style = builder.build(nativeMapView);
|
||||
if (!TextUtils.isEmpty(builder.getUrl())) {
|
||||
nativeMapView.setStyleUrl(builder.getUrl());
|
||||
@@ -842,13 +842,21 @@ public final class MapboxMap {
|
||||
if (style != null) {
|
||||
style.onDidFinishLoadingStyle();
|
||||
locationComponent.onFinishLoadingStyle();
|
||||
for (Style.OnStyleLoaded styleLoadedCallback : styleLoadedCallbacks) {
|
||||
|
||||
// notify the listener provided with the style setter
|
||||
if (styleLoadedCallback != null) {
|
||||
styleLoadedCallback.onStyleLoaded(style);
|
||||
}
|
||||
|
||||
// notify style getters
|
||||
for (Style.OnStyleLoaded styleGetter : awaitingStyleGetters) {
|
||||
styleGetter.onStyleLoaded(style);
|
||||
}
|
||||
} else {
|
||||
MapStrictMode.strictModeViolation("No style to provide.");
|
||||
}
|
||||
styleLoadedCallbacks.clear();
|
||||
styleLoadedCallback = null;
|
||||
awaitingStyleGetters.clear();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -866,7 +874,7 @@ public final class MapboxMap {
|
||||
* @return The {@code Marker} that was added to the map
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
@@ -885,7 +893,7 @@ public final class MapboxMap {
|
||||
* @return The {@code Marker} that was added to the map
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
@@ -904,7 +912,7 @@ public final class MapboxMap {
|
||||
* @return A list of the {@code Marker}s that were added to the map
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
@@ -921,7 +929,7 @@ public final class MapboxMap {
|
||||
* @param updatedMarker An updated marker object
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void updateMarker(@NonNull Marker updatedMarker) {
|
||||
@@ -935,7 +943,7 @@ public final class MapboxMap {
|
||||
* @return The {@code Polyine} that was added to the map
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
@@ -950,7 +958,7 @@ public final class MapboxMap {
|
||||
* @return A list of the {@code Polyline}s that were added to the map.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
@@ -964,7 +972,7 @@ public final class MapboxMap {
|
||||
* @param polyline An updated polyline object.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void updatePolyline(@NonNull Polyline polyline) {
|
||||
@@ -978,7 +986,7 @@ public final class MapboxMap {
|
||||
* @return The {@code Polygon} that was added to the map.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
@@ -993,7 +1001,7 @@ public final class MapboxMap {
|
||||
* @return A list of the {@code Polygon}s that were added to the map
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
@@ -1007,7 +1015,7 @@ public final class MapboxMap {
|
||||
* @param polygon An updated polygon object
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void updatePolygon(@NonNull Polygon polygon) {
|
||||
@@ -1023,7 +1031,7 @@ public final class MapboxMap {
|
||||
* @param marker Marker to remove
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void removeMarker(@NonNull Marker marker) {
|
||||
@@ -1039,7 +1047,7 @@ public final class MapboxMap {
|
||||
* @param polyline Polyline to remove
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void removePolyline(@NonNull Polyline polyline) {
|
||||
@@ -1055,7 +1063,7 @@ public final class MapboxMap {
|
||||
* @param polygon Polygon to remove
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void removePolygon(@NonNull Polygon polygon) {
|
||||
@@ -1068,7 +1076,7 @@ public final class MapboxMap {
|
||||
* @param annotation The annotation object to remove.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void removeAnnotation(@NonNull Annotation annotation) {
|
||||
@@ -1081,7 +1089,7 @@ public final class MapboxMap {
|
||||
* @param id The identifier associated to the annotation to be removed
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void removeAnnotation(long id) {
|
||||
@@ -1094,7 +1102,7 @@ public final class MapboxMap {
|
||||
* @param annotationList A list of annotation objects to remove.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void removeAnnotations(@NonNull List<? extends Annotation> annotationList) {
|
||||
@@ -1103,9 +1111,10 @@ public final class MapboxMap {
|
||||
|
||||
/**
|
||||
* Removes all annotations from the map.
|
||||
*
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void removeAnnotations() {
|
||||
@@ -1114,9 +1123,10 @@ public final class MapboxMap {
|
||||
|
||||
/**
|
||||
* Removes all markers, polylines, polygons, overlays, etc from the map.
|
||||
*
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void clear() {
|
||||
@@ -1130,7 +1140,7 @@ public final class MapboxMap {
|
||||
* @return An annotation with a matched id, null is returned if no match was found
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
@@ -1145,7 +1155,7 @@ public final class MapboxMap {
|
||||
* list will not update the map
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
@@ -1160,7 +1170,7 @@ public final class MapboxMap {
|
||||
* list will not update the map.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
@@ -1175,7 +1185,7 @@ public final class MapboxMap {
|
||||
* list will not update the map.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
@@ -1190,7 +1200,7 @@ public final class MapboxMap {
|
||||
* list will not update the map.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
@@ -1205,7 +1215,7 @@ public final class MapboxMap {
|
||||
* To unset the callback, use null.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setOnMarkerClickListener(@Nullable OnMarkerClickListener listener) {
|
||||
@@ -1219,7 +1229,7 @@ public final class MapboxMap {
|
||||
* To unset the callback, use null.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setOnPolygonClickListener(@Nullable OnPolygonClickListener listener) {
|
||||
@@ -1233,7 +1243,7 @@ public final class MapboxMap {
|
||||
* To unset the callback, use null.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setOnPolylineClickListener(@Nullable OnPolylineClickListener listener) {
|
||||
@@ -1251,7 +1261,7 @@ public final class MapboxMap {
|
||||
* @param marker The marker to select.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void selectMarker(@NonNull Marker marker) {
|
||||
@@ -1264,9 +1274,10 @@ public final class MapboxMap {
|
||||
|
||||
/**
|
||||
* Deselects any currently selected marker. All markers will have it's info window closed.
|
||||
*
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void deselectMarkers() {
|
||||
@@ -1279,7 +1290,7 @@ public final class MapboxMap {
|
||||
* @param marker the marker to deselect
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void deselectMarker(@NonNull Marker marker) {
|
||||
@@ -1292,7 +1303,7 @@ public final class MapboxMap {
|
||||
* @return The currently selected marker.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
@@ -1315,7 +1326,7 @@ public final class MapboxMap {
|
||||
* To unset the callback, use null.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setInfoWindowAdapter(@Nullable InfoWindowAdapter infoWindowAdapter) {
|
||||
@@ -1328,7 +1339,7 @@ public final class MapboxMap {
|
||||
* @return The callback to be invoked when an info window will be shown.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
@@ -1342,7 +1353,7 @@ public final class MapboxMap {
|
||||
* @param allow If true, map allows concurrent multiple infowindows to be shown.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAllowConcurrentMultipleOpenInfoWindows(boolean allow) {
|
||||
@@ -1355,7 +1366,7 @@ public final class MapboxMap {
|
||||
* @return If true, map allows concurrent multiple infowindows to be shown.
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isAllowConcurrentMultipleOpenInfoWindows() {
|
||||
@@ -2180,7 +2191,7 @@ public final class MapboxMap {
|
||||
* @see MapboxMap#setOnMarkerClickListener(OnMarkerClickListener)
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public interface OnMarkerClickListener {
|
||||
@@ -2199,7 +2210,7 @@ public final class MapboxMap {
|
||||
* @see MapboxMap#setOnPolygonClickListener(OnPolygonClickListener)
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public interface OnPolygonClickListener {
|
||||
@@ -2217,7 +2228,7 @@ public final class MapboxMap {
|
||||
* @see MapboxMap#setOnPolylineClickListener(OnPolylineClickListener)
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public interface OnPolylineClickListener {
|
||||
@@ -2280,7 +2291,7 @@ public final class MapboxMap {
|
||||
* @see MapboxMap#setInfoWindowAdapter(InfoWindowAdapter)
|
||||
* @deprecated As of 7.0.0,
|
||||
* use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
* Mapbox Annotation Plugin</a> instead
|
||||
*/
|
||||
@Deprecated
|
||||
public interface InfoWindowAdapter {
|
||||
|
||||
Reference in New Issue
Block a user