From 60b0e78e0ef7357cf6ef260a6df4241b2c5503db Mon Sep 17 00:00:00 2001 From: Braden Ewing Date: Wed, 25 Nov 2015 17:33:03 -0700 Subject: [PATCH] Improve quickzooming on Android --- .../java/com/mapbox/mapboxsdk/views/MapView.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java index 0e4d487af..ec805fdfa 100644 --- a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java +++ b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java @@ -2467,13 +2467,12 @@ public final class MapView extends FrameLayout { switch (e.getAction()) { case MotionEvent.ACTION_DOWN: - mQuickZoom = false; break; case MotionEvent.ACTION_MOVE: - mQuickZoom = true; break; case MotionEvent.ACTION_UP: if (mQuickZoom) { + mQuickZoom = false; break; } @@ -2594,7 +2593,7 @@ public final class MapView extends FrameLayout { // Called for a long press @Override public void onLongPress(MotionEvent e) { - if (mOnMapLongClickListener != null) { + if (mOnMapLongClickListener != null && !mQuickZoom) { LatLng point = fromScreenLocation(new PointF(e.getX(), e.getY())); mOnMapLongClickListener.onMapLongClick(point); } @@ -2651,7 +2650,7 @@ public final class MapView extends FrameLayout { } } - // This class handles two finger gestures + // This class handles two finger gestures and double-tap drag gestures private class ScaleGestureListener extends ScaleGestureDetector.SimpleOnScaleGestureListener { long mBeginTime = 0; @@ -2676,8 +2675,8 @@ public final class MapView extends FrameLayout { mZoomStarted = false; } - // Called each time one of the two fingers moves - // Called for pinch zooms + // Called each time a finger moves + // Called for pinch zooms and quickzooms/quickscales @Override public boolean onScale(ScaleGestureDetector detector) { if (!mZoomEnabled) { @@ -2705,6 +2704,9 @@ public final class MapView extends FrameLayout { // Cancel any animation mNativeMapView.cancelTransitions(); + // Gesture is a quickzoom if there aren't two fingers + mQuickZoom = !mTwoTap; + // Scale the map if (!mQuickZoom && mUserLocationView.getMyLocationTrackingMode() == MyLocationTracking.TRACKING_NONE) { // around gesture