Add isLayerReady check in LocationComponent before updating compass listener. (#19)
This commit is contained in:
@@ -1289,7 +1289,7 @@ public final class LocationComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isComponentInitialized || !isComponentStarted || !isEnabled) {
|
||||
if (!isComponentInitialized || !isComponentStarted || !isEnabled || !isLayerReady) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -386,6 +386,23 @@ class LocationComponentTest {
|
||||
verify(compassEngine, never()).addCompassListener(any(CompassListener::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun compass_notAddListenerWhenLayerNotReady() {
|
||||
locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(locationLayerController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.renderMode = RenderMode.COMPASS
|
||||
|
||||
verify(compassEngine, times(1)).addCompassListener(any(CompassListener::class.java))
|
||||
|
||||
locationComponent.onStartLoadingMap()
|
||||
// Layer should be disabled at this point
|
||||
locationComponent.setCameraMode(CameraMode.TRACKING_COMPASS)
|
||||
verify(compassEngine, times(1)).addCompassListener(any(CompassListener::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun developerAnimationCalled() {
|
||||
locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
|
||||
|
||||
@@ -233,8 +233,10 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
|
||||
return;
|
||||
}
|
||||
|
||||
String styleUrl = Style.DARK.equals(mapboxMap.getStyle().getUri()) ? Style.LIGHT : Style.DARK;
|
||||
mapboxMap.setStyle(new Style.Builder().fromUri(styleUrl));
|
||||
mapboxMap.getStyle(style -> {
|
||||
String styleUrl = Style.DARK.equals(style.getUri()) ? Style.LIGHT : Style.DARK;
|
||||
mapboxMap.setStyle(new Style.Builder().fromUri(styleUrl));
|
||||
});
|
||||
}
|
||||
|
||||
private void disableGesturesManagement() {
|
||||
|
||||
Reference in New Issue
Block a user