[android] - ignore location tracking mode based animations when the camera is transitioning
This commit is contained in:
@@ -726,6 +726,10 @@ public final class LocationComponent {
|
||||
* If you are not using any of {@link CameraMode} modes,
|
||||
* use one of {@link MapboxMap#moveCamera(CameraUpdate)},
|
||||
* {@link MapboxMap#easeCamera(CameraUpdate)} or {@link MapboxMap#animateCamera(CameraUpdate)} instead.
|
||||
* <p>
|
||||
* If the camera is transitioning when the zoom change is requested, the call is going to be ignored.
|
||||
* Use {@link CameraTransitionListener} to chain the animations, or provide the zoom as a camera change argument.
|
||||
* </p>
|
||||
*
|
||||
* @param zoomLevel The desired zoom level.
|
||||
* @param animationDuration The zoom animation duration.
|
||||
@@ -741,6 +745,10 @@ public final class LocationComponent {
|
||||
"LocationComponent#zoomWhileTracking method can only be used",
|
||||
" when a camera mode other than CameraMode#NONE is engaged."));
|
||||
return;
|
||||
} else if (locationCameraController.isTransitioning()) {
|
||||
Logger.e(TAG,
|
||||
"LocationComponent#zoomWhileTracking method call is ignored because the camera mode is transitioning");
|
||||
return;
|
||||
}
|
||||
locationAnimatorCoordinator.feedNewZoomLevel(zoomLevel, mapboxMap.getCameraPosition(), animationDuration, callback);
|
||||
}
|
||||
@@ -751,6 +759,10 @@ public final class LocationComponent {
|
||||
* If you are not using any of {@link CameraMode} modes,
|
||||
* use one of {@link MapboxMap#moveCamera(CameraUpdate)},
|
||||
* {@link MapboxMap#easeCamera(CameraUpdate)} or {@link MapboxMap#animateCamera(CameraUpdate)} instead.
|
||||
* <p>
|
||||
* If the camera is transitioning when the zoom change is requested, the call is going to be ignored.
|
||||
* Use {@link CameraTransitionListener} to chain the animations, or provide the zoom as a camera change argument.
|
||||
* </p>
|
||||
*
|
||||
* @param zoomLevel The desired zoom level.
|
||||
* @param animationDuration The zoom animation duration.
|
||||
@@ -766,6 +778,10 @@ public final class LocationComponent {
|
||||
* If you are not using any of {@link CameraMode} modes,
|
||||
* use one of {@link MapboxMap#moveCamera(CameraUpdate)},
|
||||
* {@link MapboxMap#easeCamera(CameraUpdate)} or {@link MapboxMap#animateCamera(CameraUpdate)} instead.
|
||||
* <p>
|
||||
* If the camera is transitioning when the zoom change is requested, the call is going to be ignored.
|
||||
* Use {@link CameraTransitionListener} to chain the animations, or provide the zoom as a camera change argument.
|
||||
* </p>
|
||||
*
|
||||
* @param zoomLevel The desired zoom level.
|
||||
*/
|
||||
@@ -788,6 +804,10 @@ public final class LocationComponent {
|
||||
* If you are not using any of {@link CameraMode} modes,
|
||||
* use one of {@link MapboxMap#moveCamera(CameraUpdate)},
|
||||
* {@link MapboxMap#easeCamera(CameraUpdate)} or {@link MapboxMap#animateCamera(CameraUpdate)} instead.
|
||||
* <p>
|
||||
* If the camera is transitioning when the tilt change is requested, the call is going to be ignored.
|
||||
* Use {@link CameraTransitionListener} to chain the animations, or provide the tilt as a camera change argument.
|
||||
* </p>
|
||||
*
|
||||
* @param tilt The desired camera tilt.
|
||||
* @param animationDuration The tilt animation duration.
|
||||
@@ -803,6 +823,10 @@ public final class LocationComponent {
|
||||
"LocationComponent#tiltWhileTracking method can only be used",
|
||||
" when a camera mode other than CameraMode#NONE is engaged."));
|
||||
return;
|
||||
} else if (locationCameraController.isTransitioning()) {
|
||||
Logger.e(TAG,
|
||||
"LocationComponent#tiltWhileTracking method call is ignored because the camera mode is transitioning");
|
||||
return;
|
||||
}
|
||||
locationAnimatorCoordinator.feedNewTilt(tilt, mapboxMap.getCameraPosition(), animationDuration, callback);
|
||||
}
|
||||
@@ -813,6 +837,10 @@ public final class LocationComponent {
|
||||
* If you are not using any of {@link CameraMode} modes,
|
||||
* use one of {@link MapboxMap#moveCamera(CameraUpdate)},
|
||||
* {@link MapboxMap#easeCamera(CameraUpdate)} or {@link MapboxMap#animateCamera(CameraUpdate)} instead.
|
||||
* <p>
|
||||
* If the camera is transitioning when the tilt change is requested, the call is going to be ignored.
|
||||
* Use {@link CameraTransitionListener} to chain the animations, or provide the tilt as a camera change argument.
|
||||
* </p>
|
||||
*
|
||||
* @param tilt The desired camera tilt.
|
||||
* @param animationDuration The tilt animation duration.
|
||||
@@ -828,6 +856,10 @@ public final class LocationComponent {
|
||||
* If you are not using any of {@link CameraMode} modes,
|
||||
* use one of {@link MapboxMap#moveCamera(CameraUpdate)},
|
||||
* {@link MapboxMap#easeCamera(CameraUpdate)} or {@link MapboxMap#animateCamera(CameraUpdate)} instead.
|
||||
* <p>
|
||||
* If the camera is transitioning when the tilt change is requested, the call is going to be ignored.
|
||||
* Use {@link CameraTransitionListener} to chain the animations, or provide the tilt as a camera change argument.
|
||||
* </p>
|
||||
*
|
||||
* @param tilt The desired camera tilt.
|
||||
*/
|
||||
|
||||
@@ -1288,6 +1288,36 @@ class LocationComponentTest : EspressoTest() {
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun animators_dontZoomWhileTransitioning() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.isLocationComponentEnabled = true
|
||||
component.forceLocationUpdate(location)
|
||||
|
||||
val zoom = mapboxMap.cameraPosition.zoom
|
||||
component.setCameraMode(CameraMode.TRACKING_GPS, 500L, null, null, null, null)
|
||||
component.zoomWhileTracking(16.0, 1000)
|
||||
uiController.loopMainThreadForAtLeast(1000)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
|
||||
assertEquals(zoom, mapboxMap.cameraPosition.zoom, 0.0001)
|
||||
}
|
||||
}
|
||||
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
fun animators_cancelZoomWhileTracking() {
|
||||
@@ -1433,6 +1463,36 @@ class LocationComponentTest : EspressoTest() {
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun animators_dontTiltWhileTransitioning() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.isLocationComponentEnabled = true
|
||||
component.forceLocationUpdate(location)
|
||||
|
||||
val tilt = mapboxMap.cameraPosition.tilt
|
||||
component.setCameraMode(CameraMode.TRACKING_GPS, 500L, null, null, null, null)
|
||||
component.tiltWhileTracking(30.0, 1000)
|
||||
uiController.loopMainThreadForAtLeast(1000)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
|
||||
assertEquals(tilt, mapboxMap.cameraPosition.tilt, 0.0001)
|
||||
}
|
||||
}
|
||||
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
fun animators_cancelTiltWhileTracking() {
|
||||
|
||||
Reference in New Issue
Block a user