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 fc6668d1dde..d0d0281a456 100644 --- a/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java +++ b/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java @@ -101,8 +101,8 @@ private int convertPxToDp(int px) { } 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 @@ private final boolean isConsideredDoubleTap(MotionEvent firstDown, } private static final boolean isConfirmedScale(MotionEvent secondDown, - MotionEvent moveEvent) { + MotionEvent moveEvent) { if (secondDown == null || moveEvent == null) { return false; } @@ -139,12 +139,12 @@ public float getCenterY() { } 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 7f8c8075e30..255e8966984 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -830,16 +830,12 @@ public boolean onTouchEvent(MotionEvent event) { 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 boolean onSingleTapConfirmed(MotionEvent e) { @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 eb1e4511c12..b438dbfe7ea 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' } }