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

Invoke callback if fling is valid #9192

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down