[android] - handle null getMapAsync invocations, deliver onMapReady only once

This commit is contained in:
Tobrun
2018-11-06 11:48:29 +01:00
committed by Tobrun
parent f2d9d92d26
commit f560b4f9ef

View File

@@ -1149,13 +1149,18 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
}
}
/**
* Notify listeners, clear when done
*/
private void onMapReady() {
if (onMapReadyCallbackList.size() > 0) {
// Notify listeners, clear when done
Iterator<OnMapReadyCallback> iterator = onMapReadyCallbackList.iterator();
while (iterator.hasNext()) {
OnMapReadyCallback callback = iterator.next();
callback.onMapReady(mapboxMap);
if (callback != null) {
// null checking required for #13279
callback.onMapReady(mapboxMap);
}
iterator.remove();
}
}
@@ -1190,6 +1195,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
public void onDidFinishLoadingStyle() {
if (mapboxMap != null) {
if (initialLoad) {
initialLoad = false;
mapboxMap.onPreMapReady();
onMapReady();
mapboxMap.onPostMapReady();