Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] - null check source before removing
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasPaczos authored and tobrun committed May 2, 2018
1 parent 8bf1ff1 commit 9522674
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,13 @@ public Source removeSource(@NonNull String sourceId) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,20 @@ public void perform(UiController uiController, View view) {
});
}

@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
*/
Expand Down

0 comments on commit 9522674

Please sign in to comment.