[android] do not clear native layers and sources when style is reloading

This prevents unnecessary layers blink when the same components are re-added after the style reload.
This commit is contained in:
Łukasz Paczos
2019-08-28 16:44:02 +02:00
committed by Łukasz Paczos
parent 6998e9a8ed
commit 6a4e431dbe
3 changed files with 1 additions and 21 deletions

View File

@@ -1182,7 +1182,6 @@ public final class LocationComponent {
}
isLayerReady = false;
locationLayerController.hide();
staleStateManager.onStop();
if (compassEngine != null) {
updateCompassListenerState(false);
@@ -1289,6 +1288,7 @@ public final class LocationComponent {
private void disableLocationComponent() {
isEnabled = false;
locationLayerController.hide();
onLocationLayerStop();
}

View File

@@ -523,14 +523,12 @@ public class Style {
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);
}
}

View File

@@ -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)
}
}
}