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

Commit

Permalink
[android] do not clear native layers and sources when style is reloading
Browse files Browse the repository at this point in the history
This prevents unnecessary layers blink when the same components are re-added after the style reload.
  • Loading branch information
LukasPaczos authored and Łukasz Paczos committed Aug 29, 2019
1 parent 6998e9a commit 6a4e431
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,6 @@ private void onLocationLayerStop() {
}

isLayerReady = false;
locationLayerController.hide();
staleStateManager.onStop();
if (compassEngine != null) {
updateCompassListenerState(false);
Expand Down Expand Up @@ -1289,6 +1288,7 @@ private void enableLocationComponent() {

private void disableLocationComponent() {
isEnabled = false;
locationLayerController.hide();
onLocationLayerStop();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,12 @@ void clear() {
for (Layer layer : layers.values()) {
if (layer != null) {
layer.setDetached();
nativeMap.removeLayer(layer);
}
}

for (Source source : sources.values()) {
if (source != null) {
source.setDetached();
nativeMap.removeSource(source);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,22 +405,4 @@ class StyleTest {
Assert.assertEquals("Layer that failed to be added shouldn't be cached", layer1, mapboxMap.style!!.getLayer("layer1"))
}
}

@Test
fun testClearRemovesSourcesFirst() {
val source1 = mockk<GeoJsonSource>(relaxed = true)
every { source1.id } returns "source1"
val layer1 = mockk<SymbolLayer>(relaxed = true)
every { layer1.id } returns "layer1"

val builder = Style.Builder().withLayer(layer1).withSource(source1)
mapboxMap.setStyle(builder)
mapboxMap.notifyStyleLoaded()
mapboxMap.setStyle(Style.MAPBOX_STREETS)

verifyOrder {
nativeMapView.removeLayer(layer1)
nativeMapView.removeSource(source1)
}
}
}

0 comments on commit 6a4e431

Please sign in to comment.