Fix rare crash LatLngAnimator (#3352)
This commit is contained in:
@@ -334,7 +334,8 @@ final class LocationAnimatorCoordinator {
|
||||
createNewCameraAdapterAnimator(ANIMATOR_TILT, new Float[] {previousTiltLevel, targetTilt}, cancelableCallback);
|
||||
}
|
||||
|
||||
private void createNewLatLngAnimator(@MapLibreAnimator.Type int animatorType, LatLng previous, LatLng target) {
|
||||
private void createNewLatLngAnimator(@MapLibreAnimator.Type int animatorType,
|
||||
@NonNull LatLng previous, @NonNull LatLng target) {
|
||||
createNewLatLngAnimator(animatorType, new LatLng[] {previous, target});
|
||||
}
|
||||
|
||||
@@ -430,6 +431,10 @@ final class LocationAnimatorCoordinator {
|
||||
|
||||
LatLng currentTarget = animator.getTarget();
|
||||
LatLng previousCameraTarget = currentCameraPosition.target;
|
||||
if (previousCameraTarget == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
createNewLatLngAnimator(ANIMATOR_CAMERA_LATLNG, previousCameraTarget, currentTarget);
|
||||
|
||||
return immediateAnimation(projection, previousCameraTarget, currentTarget);
|
||||
|
||||
@@ -583,6 +583,15 @@ class LocationAnimatorCoordinatorTest {
|
||||
assertFalse(locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_LATLNG].isStarted)
|
||||
}
|
||||
|
||||
// regression test for crash https://github.com/maplibre/maplibre-native/issues/3294
|
||||
@Test
|
||||
fun resetAllCameraAnimations_null_target() {
|
||||
locationAnimatorCoordinator.feedNewLocation(Location(""), CameraPosition.DEFAULT, true)
|
||||
|
||||
val cameraPosition = CameraPosition.Builder().build()
|
||||
locationAnimatorCoordinator.resetAllCameraAnimations(cameraPosition, false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelZoomAnimators() {
|
||||
locationAnimatorCoordinator.feedNewZoomLevel(
|
||||
|
||||
Reference in New Issue
Block a user