Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,27 @@ class LocationLayerPluginTest {
executePluginTest(pluginAction)
}

@Test
fun disablingPluginAndChangingStyleAllowsToEnableAgain() {
val pluginAction = object : GenericPluginAction.OnPerformGenericPluginAction<LocationLayerPlugin> {
override fun onGenericPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {

plugin.forceLocationUpdate(location)
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)

plugin.isLocationLayerEnabled = false
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
mapboxMap.setStyle(Style.LIGHT)
uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY)
plugin.isLocationLayerEnabled = true
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
}
}
executePluginTest(pluginAction)
}

@Test
fun lifecycle_keepsEnabledWhenStoppedAndStarted() {
val pluginAction = object : GenericPluginAction.OnPerformGenericPluginAction<LocationLayerPlugin> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,11 +623,10 @@ public void onStop() {
}

void onLocationLayerStart() {
if (isLocationLayerStarted || !isPluginStarted) {
if (!isPluginStarted) {
return;
}

isLocationLayerStarted = true;
if (isEnabled) {
if (locationEngine != null) {
locationEngine.addLocationEngineListener(locationEngineListener);
Expand All @@ -637,6 +636,12 @@ void onLocationLayerStart() {
locationLayer.show();
setCameraMode(locationLayerCamera.getCameraMode());
}

if (isLocationLayerStarted) {
return;
}

isLocationLayerStarted = true;
if (mapboxMap != null) {
mapboxMap.addOnCameraMoveListener(onCameraMoveListener);
mapboxMap.addOnCameraIdleListener(onCameraIdleListener);
Expand Down