[android] - null check source before removing
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user