[android] - allow compass update without animation (#7094)
This commit is contained in:
@@ -486,6 +486,10 @@ public class MyLocationView extends View {
|
||||
}
|
||||
|
||||
private void setCompass(double bearing) {
|
||||
setCompass(bearing, 0 /* no animation */);
|
||||
}
|
||||
|
||||
private void setCompass(double bearing, long duration) {
|
||||
float oldDir = previousDirection;
|
||||
if (directionAnimator != null) {
|
||||
oldDir = (Float) directionAnimator.getAnimatedValue();
|
||||
@@ -503,7 +507,7 @@ public class MyLocationView extends View {
|
||||
previousDirection = newDir;
|
||||
|
||||
directionAnimator = ValueAnimator.ofFloat(oldDir, newDir);
|
||||
directionAnimator.setDuration(COMPASS_UPDATE_RATE_MS);
|
||||
directionAnimator.setDuration(duration);
|
||||
directionAnimator.addUpdateListener(invalidateSelfOnUpdateListener);
|
||||
directionAnimator.start();
|
||||
}
|
||||
@@ -586,10 +590,10 @@ public class MyLocationView extends View {
|
||||
if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) {
|
||||
// Change the user location view orientation to reflect the device orientation
|
||||
rotateCamera(magneticHeading);
|
||||
setCompass(0);
|
||||
setCompass(0, COMPASS_UPDATE_RATE_MS);
|
||||
} else {
|
||||
// Change compass direction
|
||||
setCompass(magneticHeading - bearing);
|
||||
setCompass(magneticHeading - bearing, COMPASS_UPDATE_RATE_MS);
|
||||
}
|
||||
|
||||
compassUpdateNextTimestamp = currentTime + COMPASS_UPDATE_RATE_MS;
|
||||
@@ -706,7 +710,7 @@ public class MyLocationView extends View {
|
||||
if (location.hasBearing()) {
|
||||
builder.bearing(location.getBearing());
|
||||
}
|
||||
setCompass(0);
|
||||
setCompass(0, COMPASS_UPDATE_RATE_MS);
|
||||
}
|
||||
|
||||
// accuracy
|
||||
|
||||
Reference in New Issue
Block a user