From 2c7350c09375ad363e3a42f24956806a1385a7bc Mon Sep 17 00:00:00 2001 From: Tobrun Date: Tue, 7 Feb 2017 07:31:39 +0100 Subject: 7798-ObjectAnimator-rotation (#7907) --- .../java/com/mapbox/mapboxsdk/annotations/MarkerView.java | 13 ++----------- .../com/mapbox/mapboxsdk/annotations/MarkerViewManager.java | 8 ++++++++ 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations') diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java index 29f6d4dccf..220d3322cb 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java @@ -266,18 +266,9 @@ public class MarkerView extends Marker { * @param rotation the rotation value to animate to. */ public void setRotation(float rotation) { - // limit to 0 - 360 degrees - float newRotation = rotation; - while (newRotation > 360) { - newRotation -= 360; - } - while (newRotation < 0) { - newRotation += 360; - } - - this.rotation = newRotation; + this.rotation = rotation; if (markerViewManager != null) { - markerViewManager.animateRotationBy(this, newRotation); + markerViewManager.setRotation(this, rotation); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java index 710ffc329b..e6d7843d9f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java @@ -125,6 +125,14 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { } } + public void setRotation(@NonNull MarkerView marker, float rotation) { + View convertView = markerViewMap.get(marker); + if (convertView != null) { + convertView.animate().cancel(); + convertView.setRotation(rotation); + } + } + /** * Animate a MarkerView to a given alpha value. *

-- cgit v1.2.1