diff options
author | Tobrun <tobrun@mapbox.com> | 2017-06-29 09:29:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-29 09:29:23 +0200 |
commit | 200d184738a2a5c8e7cb19a0f5eaa06d34cb1774 (patch) | |
tree | 2780cb51938f6bb2fbb6da9912e1013c15c2d5cc /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java | |
parent | 34453eb4e27c0bf45027700e45ad69435f3566d7 (diff) | |
download | qtlocation-mapboxgl-200d184738a2a5c8e7cb19a0f5eaa06d34cb1774.tar.gz |
OnCameraIdle hook into quickzoom gesture (#9339)
* [android] - OnCameraIdle hook into quickzoom gesture
* double tap fix
* show MyLocationView bearing for GPS when Compass is not available, only show error about missing compass once, fix test activity.
* fix accessor lint warning
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java index 5346baa4e2..3607703ab1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java @@ -57,6 +57,7 @@ final class MapGestureDetector { private boolean quickZoom = false; private boolean scrollInProgress = false; private boolean scaleGestureOccurred = false; + private boolean recentScaleGestureOccurred = false; MapGestureDetector(Context context, Transform transform, Projection projection, UiSettings uiSettings, TrackingSettings trackingSettings, AnnotationManager annotationManager, @@ -148,7 +149,7 @@ final class MapGestureDetector { switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: // First pointer down, reset scaleGestureOccurred, used to avoid triggering a fling after a scale gesture #7666 - scaleGestureOccurred = false; + recentScaleGestureOccurred = false; transform.setGestureInProgress(true); break; @@ -274,7 +275,7 @@ final class MapGestureDetector { break; case MotionEvent.ACTION_UP: if (quickZoom) { - // insert here? + cameraChangeDispatcher.onCameraIdle(); quickZoom = false; break; } @@ -341,7 +342,7 @@ final class MapGestureDetector { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - if ((!trackingSettings.isScrollGestureCurrentlyEnabled()) || scaleGestureOccurred) { + if ((!trackingSettings.isScrollGestureCurrentlyEnabled()) || recentScaleGestureOccurred) { // don't allow a fling is scroll is disabled // and ignore when a scale gesture has occurred return false; @@ -392,12 +393,17 @@ final class MapGestureDetector { return false; } + if (scaleGestureOccurred) { + return false; + } + if (!scrollInProgress) { scrollInProgress = true; // Cancel any animation transform.cancelTransitions(); cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); + MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( getLocationFromGesture(e1.getX(), e1.getY()), MapboxEvent.GESTURE_PAN_START, transform)); @@ -432,6 +438,7 @@ final class MapGestureDetector { } scaleGestureOccurred = true; + recentScaleGestureOccurred = true; beginTime = detector.getEventTime(); MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( getLocationFromGesture(detector.getFocusX(), detector.getFocusY()), @@ -442,9 +449,11 @@ final class MapGestureDetector { // Called when fingers leave screen @Override public void onScaleEnd(ScaleGestureDetector detector) { + scaleGestureOccurred = false; beginTime = 0; scaleFactor = 1.0f; zoomStarted = false; + cameraChangeDispatcher.onCameraIdle(); } // Called each time a finger moves @@ -480,6 +489,9 @@ final class MapGestureDetector { } // Gesture is a quickzoom if there aren't two fingers + if (!quickZoom && !twoTap) { + cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); + } quickZoom = !twoTap; // make an assumption here; if the zoom center is specified by the gesture, it's NOT going @@ -492,6 +504,7 @@ final class MapGestureDetector { // arround user provided focal point transform.zoomBy(Math.log(detector.getScaleFactor()) / Math.log(2), focalPoint.x, focalPoint.y); } else if (quickZoom) { + cameraChangeDispatcher.onCameraMove(); // clamp scale factors we feed to core #7514 float scaleFactor = MathUtils.clamp(detector.getScaleFactor(), MapboxConstants.MINIMUM_SCALE_FACTOR_CLAMP, @@ -553,7 +566,7 @@ final class MapGestureDetector { // If rotate is large enough ignore a tap // Also is zoom already started, don't rotate totalAngle += detector.getRotationDegreesDelta(); - if (!zoomStarted && ((totalAngle > 20.0f) || (totalAngle < -20.0f))) { + if (totalAngle > 20.0f || totalAngle < -20.0f) { started = true; } |