Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit ef7b355

Browse files
authored
[android] - only invoke callback if fling scrolling animation isn't going to be ignored. (#9192)
1 parent da53200 commit ef7b355

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve
346346
// and ignore when a scale gesture has occurred
347347
return false;
348348
}
349-
cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
350349

351350
float screenDensity = uiSettings.getPixelRatio();
352351

@@ -362,6 +361,8 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve
362361
// cancel any animation
363362
transform.cancelTransitions();
364363

364+
cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
365+
365366
// tilt results in a bigger translation, limiting input for #5281
366367
double tilt = transform.getTilt();
367368
double tiltFactor = 1 + ((tilt != 0) ? (tilt / 10) : 0); /* 1 -> 7 */

platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void updateCameraPosition(@NonNull CameraPosition position) {
7979

8080
@Override
8181
public void onMapChanged(@MapView.MapChange int change) {
82-
if (change == REGION_DID_CHANGE_ANIMATED && cameraCancelableCallback != null) {
82+
if (change == REGION_DID_CHANGE_ANIMATED) {
8383
updateCameraPosition(invalidateCameraPosition());
8484
if (cameraCancelableCallback != null) {
8585
cameraCancelableCallback.onFinish();
@@ -116,8 +116,8 @@ final void easeCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs,
116116

117117
if (callback != null) {
118118
cameraCancelableCallback = callback;
119-
mapView.addOnMapChangedListener(this);
120119
}
120+
mapView.addOnMapChangedListener(this);
121121
mapView.easeTo(cameraPosition.bearing, cameraPosition.target, durationMs, cameraPosition.tilt,
122122
cameraPosition.zoom, easingInterpolator);
123123
}
@@ -134,9 +134,8 @@ final void animateCamera(MapboxMap mapboxMap, CameraUpdate update, int durationM
134134

135135
if (callback != null) {
136136
cameraCancelableCallback = callback;
137-
mapView.addOnMapChangedListener(this);
138137
}
139-
138+
mapView.addOnMapChangedListener(this);
140139
mapView.flyTo(cameraPosition.bearing, cameraPosition.target, durationMs, cameraPosition.tilt,
141140
cameraPosition.zoom);
142141
}

0 commit comments

Comments
 (0)