summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Paczos <lukasz.paczos@mapbox.com>2019-07-30 17:55:57 +0300
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2019-07-30 17:55:57 +0300
commite267a54b7cbe28540726aea9906441b37ff51709 (patch)
treeb73c3185b2b2707e3a186f4f63b765073efa23e9
parentf86f0226dd7f87fef97378cff225754ae5d69c90 (diff)
downloadqtlocation-mapboxgl-upstream/lp-location-animation-15246.tar.gz
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java26
3 files changed, 33 insertions, 1 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java
index 6337287770..eff8073d7d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java
@@ -362,7 +362,9 @@ final class LocationAnimatorCoordinator {
float currentGpsBearingTarget = gpsBearingAnimator.getTarget();
createNewFloatAnimator(ANIMATOR_LAYER_GPS_BEARING, currentGpsBearing, currentGpsBearingTarget);
- playAnimators(getAnimationDuration(), ANIMATOR_LAYER_LATLNG, ANIMATOR_LAYER_GPS_BEARING);
+ long duration = latLngAnimator.getDuration() - latLngAnimator.getCurrentPlayTime();
+
+ playAnimators(duration, ANIMATOR_LAYER_LATLNG, ANIMATOR_LAYER_GPS_BEARING);
}
if (compassBearingAnimator != null) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java
index d22f7a8514..79d2e02bf1 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java
@@ -102,6 +102,10 @@ final class LocationCameraController {
long transitionDuration,
@Nullable Double zoom, @Nullable Double bearing, @Nullable Double tilt,
@Nullable OnLocationCameraTransitionListener internalTransitionListener) {
+ if (this.cameraMode == cameraMode) {
+ return;
+ }
+
final boolean wasTracking = isLocationTracking();
this.cameraMode = cameraMode;
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java
index 7fb018d235..d1b8642c31 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java
@@ -142,6 +142,32 @@ public class LocationCameraControllerTest {
}
@Test
+ public void setCameraMode_doNotNotifyAboutDuplicates_NONE() {
+ OnCameraTrackingChangedListener internalTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
+ LocationCameraController camera = buildCamera(internalTrackingChangedListener);
+ camera.initializeOptions(mock(LocationComponentOptions.class));
+ int cameraMode = NONE;
+
+ camera.setCameraMode(cameraMode);
+ camera.setCameraMode(cameraMode);
+
+ verify(internalTrackingChangedListener, times(1)).onCameraTrackingChanged(cameraMode);
+ }
+
+ @Test
+ public void setCameraMode_doNotNotifyAboutDuplicates_TRACKING_GPS() {
+ OnCameraTrackingChangedListener internalTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
+ LocationCameraController camera = buildCamera(internalTrackingChangedListener);
+ camera.initializeOptions(mock(LocationComponentOptions.class));
+ int cameraMode = TRACKING_GPS;
+
+ camera.setCameraMode(cameraMode);
+ camera.setCameraMode(cameraMode);
+
+ verify(internalTrackingChangedListener, times(1)).onCameraTrackingChanged(cameraMode);
+ }
+
+ @Test
public void setCameraMode_cancelTransitionsWhenSet() {
MapboxMap mapboxMap = mock(MapboxMap.class);
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));