From 2ee13fc92316e104578cbbb4a8922d361efc9576 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Mon, 5 Aug 2019 22:09:48 +0300 Subject: [PATCH] Fix jumping animation --- .../mapcontextmenu/MapContextMenuFragment.java | 16 ++++++---------- .../plus/views/AnimateDraggingMapThread.java | 3 ++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 80b988dd59..0a61a7abf0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -1698,7 +1698,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo public void centerMarkerLocation() { centered = true; - showOnMap(menu.getLatLon(), true, true, false, getZoom()); + showOnMap(menu.getLatLon(), true, false, getZoom()); } private int getZoom() { @@ -1722,8 +1722,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo cp.setCenterLocation(0.5f, map.getMapPosition() == OsmandSettings.BOTTOM_CONSTANT ? 0.15f : 0.5f); cp.setLatLonCenter(flat, flon); cp.setZoom(zoom); - flat = cp.getLatFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2); - flon = cp.getLonFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2); + flat = cp.getLatFromPixel(cp.getPixWidth() / 2f, cp.getPixHeight() / 2f); + flon = cp.getLonFromPixel(cp.getPixWidth() / 2f, cp.getPixHeight() / 2f); if (updateOrigXY) { origMarkerX = cp.getCenterPixelX(); @@ -1732,21 +1732,17 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo return new LatLon(flat, flon); } - private void showOnMap(LatLon latLon, boolean updateCoords, boolean needMove, boolean alreadyAdjusted, int zoom) { + private void showOnMap(LatLon latLon, boolean updateCoords, boolean alreadyAdjusted, int zoom) { AnimateDraggingMapThread thread = map.getAnimatedDraggingThread(); LatLon calcLatLon = calculateCenterLatLon(latLon, zoom, updateCoords); if (updateCoords) { mapCenter = calcLatLon; menu.setMapCenter(mapCenter); } - if (!alreadyAdjusted) { calcLatLon = getAdjustedMarkerLocation(getPosY(), calcLatLon, true, zoom); } - - if (needMove) { - thread.startMoving(calcLatLon.getLatitude(), calcLatLon.getLongitude(), zoom, true); - } + thread.startMoving(calcLatLon.getLatitude(), calcLatLon.getLongitude(), zoom, true); } private void setAddressLocation() { @@ -2021,7 +2017,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo } if (animated) { - showOnMap(latlon, false, true, true, zoom); + showOnMap(latlon, false, true, zoom); } else { if (dZoom != 0) { map.setIntZoom(zoom); diff --git a/OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java b/OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java index 461dd0eda0..f753837253 100644 --- a/OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java +++ b/OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java @@ -180,6 +180,7 @@ public class AnimateDraggingMapThread { public void startMoving(final double finalLat, final double finalLon, final int endZoom, final boolean notifyListener, final Runnable finishAnimationCallback) { + boolean wasAnimating = isAnimating(); stopAnimatingSync(); final RotatedTileBox rb = tileView.getCurrentRotatedTileBox().copy(); @@ -202,7 +203,7 @@ public class AnimateDraggingMapThread { final int moveZoom = rb.getZoom(); // check if animation needed skipAnimation = skipAnimation || (Math.abs(moveZoom - startZoom) >= 3 || Math.abs(endZoom - moveZoom) > 3); - if (skipAnimation) { + if (skipAnimation || wasAnimating) { tileView.setLatLonAnimate(finalLat, finalLon, notifyListener); tileView.setFractionalZoom(endZoom, 0, notifyListener); if (finishAnimationCallback != null) {