[android] Animate MylocationView direction

Fixes #4942
This commit is contained in:
Cameron Mace
2016-05-11 15:35:20 -04:00
committed by Tobrun
parent 56979500d8
commit cdda083a6f

View File

@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.maps.widgets;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
@@ -62,6 +63,7 @@ public class MyLocationView extends View {
private ValueAnimator locationChangeAnimator;
private ValueAnimator accuracyAnimator;
private ObjectAnimator directionAnimator;
private Drawable foregroundDrawable;
private Drawable foregroundBearingDrawable;
@@ -390,7 +392,16 @@ public class MyLocationView extends View {
newDir -= 360.f;
}
compassDirection = newDir;
invalidate();
if (directionAnimator != null) {
directionAnimator.end();
directionAnimator = null;
}
directionAnimator = ObjectAnimator.ofFloat(this, View.ROTATION, oldDir, newDir);
directionAnimator.setDuration(1000);
directionAnimator.start();
} else {
compassDirection = 0;
}