From 1d2f2a9e8b638e95dcb8fd0e3788357a3c19d4d6 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Tue, 6 Jun 2017 08:11:22 +0200 Subject: [PATCH] [android] - only invoke callback if fling scrolling animation isn't going to be ignored. --- .../java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java | 3 ++- .../src/main/java/com/mapbox/mapboxsdk/maps/Transform.java | 7 +++---- 2 files changed, 5 insertions(+), 5 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 33e13c5ecc3..5346baa4e2c 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 @@ -346,7 +346,6 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve // and ignore when a scale gesture has occurred return false; } - cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); float screenDensity = uiSettings.getPixelRatio(); @@ -362,6 +361,8 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve // cancel any animation transform.cancelTransitions(); + cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); + // tilt results in a bigger translation, limiting input for #5281 double tilt = transform.getTilt(); double tiltFactor = 1 + ((tilt != 0) ? (tilt / 10) : 0); /* 1 -> 7 */ diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java index 7f44e0de070..9a8997014a5 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java @@ -79,7 +79,7 @@ void updateCameraPosition(@NonNull CameraPosition position) { @Override public void onMapChanged(@MapView.MapChange int change) { - if (change == REGION_DID_CHANGE_ANIMATED && cameraCancelableCallback != null) { + if (change == REGION_DID_CHANGE_ANIMATED) { updateCameraPosition(invalidateCameraPosition()); if (cameraCancelableCallback != null) { cameraCancelableCallback.onFinish(); @@ -116,8 +116,8 @@ final void easeCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs, if (callback != null) { cameraCancelableCallback = callback; - mapView.addOnMapChangedListener(this); } + mapView.addOnMapChangedListener(this); mapView.easeTo(cameraPosition.bearing, cameraPosition.target, durationMs, cameraPosition.tilt, cameraPosition.zoom, easingInterpolator); } @@ -134,9 +134,8 @@ final void animateCamera(MapboxMap mapboxMap, CameraUpdate update, int durationM if (callback != null) { cameraCancelableCallback = callback; - mapView.addOnMapChangedListener(this); } - + mapView.addOnMapChangedListener(this); mapView.flyTo(cameraPosition.bearing, cameraPosition.target, durationMs, cameraPosition.tilt, cameraPosition.zoom); }