From 0a8bd164e68fb41d90b82f326d5ca4bc3c76bc3b Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Sat, 1 Apr 2017 16:18:03 +0300 Subject: [PATCH] Fix #3420 --- .../plus/base/MapViewTrackingUtilities.java | 16 ++++++++++------ .../plus/views/AnimateDraggingMapThread.java | 19 ++++++------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index 111e1981a1..6963551b3c 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -178,12 +178,13 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc zoom = autozoom(location); } int currentMapRotation = settings.ROTATE_MAP.get(); - boolean smallSpeed = isSmallSpeedForCompass(location); + boolean smallSpeedForCompass = isSmallSpeedForCompass(location); + boolean smallSpeedForAnimation = isSmallSpeedForAnimation(location); // boolean virtualBearing = fMode && settings.SNAP_TO_ROAD.get(); - showViewAngle = (!location.hasBearing() || smallSpeed) && (tb != null && + showViewAngle = (!location.hasBearing() || smallSpeedForCompass) && (tb != null && tb.containsLatLon(location.getLatitude(), location.getLongitude())); if (currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) { - if (location.hasBearing() && !smallSpeed) { + if (location.hasBearing() && !smallSpeedForCompass) { // special case when bearing equals to zero (we don't change anything) if (location.getBearing() != 0f) { rotation = -location.getBearing(); @@ -193,7 +194,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc showViewAngle = routePlanningMode; // disable compass rotation in that mode } registerUnregisterSensor(location); - if (settings.ANIMATE_MY_LOCATION.get()) { + if (settings.ANIMATE_MY_LOCATION.get() && !smallSpeedForAnimation) { mapView.getAnimatedDraggingThread().startMoving( location.getLatitude(), location.getLongitude(), zoom, rotation, false); } else { @@ -230,8 +231,11 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc public static boolean isSmallSpeedForCompass(Location location) { return !location.hasSpeed() || location.getSpeed() < 0.5; } - - + + public static boolean isSmallSpeedForAnimation(Location location) { + return !location.hasSpeed() || location.getSpeed() < 1.5; + } + public boolean isShowViewAngle() { return showViewAngle; } diff --git a/OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java b/OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java index 47e2a8766f..5a98cf3231 100644 --- a/OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java +++ b/OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java @@ -160,27 +160,18 @@ public class AnimateDraggingMapThread { public void run() { setTargetValues(zoom, finalLat, finalLon); boolean animateZoom = finalZoom != null && (zoom != startZoom || startZoomFP != 0); + boolean animateRotation = rotation != startRotaton; if (animateZoom) { animatingZoomInThread(startZoom, startZoomFP, zoom, zoomFP, NAV_ANIMATION_TIME, notifyListener); } - if (rotation != startRotaton) { - AnimateDraggingMapThread.this.targetRotate = rotation; - //animatingRotateInThread(rotation, NAV_ANIMATION_TIME, notifyListener); + if (animateRotation) { + animatingRotateInThread(rotation, 500f, notifyListener); } - pendingRotateAnimation(); if (!stopped){ animatingMoveInThread(mMoveX, mMoveY, NAV_ANIMATION_TIME, notifyListener); } - - if (!stopped){ - //tileView.setLatLonAnimate(finalLat, finalLon, notifyListener); - } - - if (animateZoom) { - //tileView.setFractionalZoom(zoom, zoomFP, notifyListener); - } } }); } @@ -254,6 +245,7 @@ public class AnimateDraggingMapThread { while (!stopped) { normalizedTime = (SystemClock.uptimeMillis() - timeMillis) / animationTime; if (normalizedTime > 1f) { + tileView.rotateToAnimate(rotate); break; } float interpolation = interpolator.getInterpolation(normalizedTime); @@ -264,8 +256,9 @@ public class AnimateDraggingMapThread { stopped = true; } } + } else { + tileView.rotateToAnimate(rotate); } - tileView.rotateToAnimate(rotate); } private void animatingMoveInThread(float moveX, float moveY, float animationTime,