From 8b24f5684bb680f8690e555817203fab130d6fd0 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Tue, 7 Jun 2016 16:46:41 +0300 Subject: [PATCH] Better gesture handling. --- .../plus/views/DoubleTapScaleDetector.java | 14 ++++----- .../osmand/plus/views/OsmandMapTileView.java | 30 +++++++++---------- build.gradle | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java b/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java index fc6668d1dd..d0d0281a45 100644 --- a/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java +++ b/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java @@ -101,8 +101,8 @@ public class DoubleTapScaleDetector { } private final boolean isConsideredDoubleTap(MotionEvent firstDown, - MotionEvent firstUp, - MotionEvent secondDown) { + MotionEvent firstUp, + MotionEvent secondDown) { if (firstDown == null || firstUp == null || secondDown == null) { return false; } @@ -123,7 +123,7 @@ public class DoubleTapScaleDetector { } private static final boolean isConfirmedScale(MotionEvent secondDown, - MotionEvent moveEvent) { + MotionEvent moveEvent) { if (secondDown == null || moveEvent == null) { return false; } @@ -139,12 +139,12 @@ public class DoubleTapScaleDetector { } public interface DoubleTapZoomListener { - public void onZoomStarted(PointF centerPoint); + void onZoomStarted(PointF centerPoint); - public void onZooming(double relativeToStart); + void onZooming(double relativeToStart); - public void onZoomEnded(double relativeToStart); + void onZoomEnded(double relativeToStart); - public void onGestureInit(float x1, float y1, float x2, float y2); + void onGestureInit(float x1, float y1, float x2, float y2); } } diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index 7f8c8075e3..255e896698 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -830,16 +830,12 @@ public class OsmandMapTileView implements IMapDownloaderCallback { animatedDraggingThread.stopAnimating(); } for (int i = layers.size() - 1; i >= 0; i--) { - if (layers.get(i).onTouchEvent(event, getCurrentRotatedTileBox())) { - return true; - } + layers.get(i).onTouchEvent(event, getCurrentRotatedTileBox()); } - if (!multiTouchSupport.onTouchEvent(event)) { - /* return */ - doubleTapScaleDetector.onTouchEvent(event); - if (!doubleTapScaleDetector.isInZoomMode()) { - gestureDetector.onTouchEvent(event); - } + final boolean isMultiTouch = multiTouchSupport.onTouchEvent(event); + doubleTapScaleDetector.onTouchEvent(event); + if (!isMultiTouch && !doubleTapScaleDetector.isInZoomMode()) { + gestureDetector.onTouchEvent(event); } return true; } @@ -1100,13 +1096,17 @@ public class OsmandMapTileView implements IMapDownloaderCallback { @Override public boolean onDoubleTap(MotionEvent e) { LOG.debug("onDoubleTap getZoom()"); - if (isZoomingAllowed(getZoom(), 1.1f)) { - final RotatedTileBox tb = getCurrentRotatedTileBox(); - final double lat = tb.getLatFromPixel(e.getX(), e.getY()); - final double lon = tb.getLonFromPixel(e.getX(), e.getY()); - getAnimatedDraggingThread().startMoving(lat, lon, getZoom() + 1, true); + if (!doubleTapScaleDetector.isInZoomMode()) { + if (isZoomingAllowed(getZoom(), 1.1f)) { + final RotatedTileBox tb = getCurrentRotatedTileBox(); + final double lat = tb.getLatFromPixel(e.getX(), e.getY()); + final double lon = tb.getLonFromPixel(e.getX(), e.getY()); + getAnimatedDraggingThread().startMoving(lat, lon, getZoom() + 1, true); + } + return true; + } else { + return false; } - return true; } } diff --git a/build.gradle b/build.gradle index eb1e4511c1..b438dbfe7e 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0' + classpath 'com.android.tools.build:gradle:2.1.2' } }