[android] - null check source before removing

This commit is contained in:
Łukasz Paczos
2018-04-27 12:24:32 +02:00
committed by Tobrun
parent 86a2e93294
commit 4db617c7a9
2 changed files with 19 additions and 1 deletions

View File

@@ -759,9 +759,13 @@ final class NativeMapView {
return null;
}
Source source = getSource(sourceId);
return removeSource(source);
if (source != null) {
return removeSource(source);
}
return null;
}
@Nullable
public Source removeSource(@NonNull Source source) {
if (isDestroyedOn("removeSource")) {
return null;

View File

@@ -280,6 +280,20 @@ public class RuntimeStyleTests extends BaseActivityTest {
});
}
@Test
public void testRemoveNonExistingSource() {
invoke(mapboxMap, (uiController, mapboxMap) -> mapboxMap.removeSource("source"));
}
@Test
public void testRemoveNonExistingLayer() {
invoke(mapboxMap, (uiController, mapboxMap) -> {
mapboxMap.removeLayer("layer");
mapboxMap.removeLayerAt(mapboxMap.getLayers().size() + 1);
mapboxMap.removeLayerAt(-1);
});
}
/**
* https://github.com/mapbox/mapbox-gl-native/issues/7973
*/