From 1359d92a9c9f9e5b31e1dc1ce5309c85d7f455ac Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Thu, 28 Jan 2016 17:28:57 +0200 Subject: [PATCH] Little stability improvement of doubletap scale. --- .../osmand/plus/views/DoubleTapScaleDetector.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java b/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java index 728dbdd9f8..7384854d46 100644 --- a/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java +++ b/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java @@ -104,11 +104,15 @@ public class DoubleTapScaleDetector { return false; } - int deltaX = (int) firstDown.getX() - (int) secondDown.getX(); - int deltaY = (int) firstDown.getY() - (int) secondDown.getY(); - int squared = deltaX * deltaX + deltaY * deltaY; - boolean toReturn = squared < mDoubleTapSlopSquare; - return toReturn; + int deltaXDown = (int) firstDown.getX() - (int) secondDown.getX(); + int deltaYDown = (int) firstDown.getY() - (int) secondDown.getY(); + int squaredDown = deltaXDown * deltaXDown + deltaYDown * deltaYDown; + + int deltaXUp = (int) firstDown.getX() - (int) secondDown.getX(); + int deltaYUp = (int) firstDown.getY() - (int) secondDown.getY(); + int squaredUp = deltaXUp * deltaXUp + deltaYUp * deltaYUp; + + return squaredDown < mDoubleTapSlopSquare && squaredUp < mDoubleTapSlopSquare; } private static final boolean isConfirmedScale(MotionEvent secondDown,