Fix jumping animation

This commit is contained in:
max-klaus 2019-08-05 22:09:48 +03:00
parent 5e591194c0
commit ba6d3c1c85
2 changed files with 8 additions and 11 deletions

View file

@ -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);

View file

@ -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) {