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

[android] - avoid triggering a fling gesture after a scale gesture. #7675

Merged
merged 1 commit into from
Jan 11, 2017
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
2 changes: 2 additions & 0 deletions platform/android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to
- Rename to reflect the increased responsibilities introduced in prior releases
* AnnotationManager refactor [#6067](https://github.com/mapbox/mapbox-gl-native/issues/6067)
- Extracting all business logic related to annotations into a seperate class cfr. to core and the iOS codebase
* Gesture handling bugs
- Avoid calls to onFling when while pinch zooming [#7666](https://github.com/mapbox/mapbox-gl-native/issues/7666)

## 4.2.1 - December 22, 2016

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ final class MapGestureDetector {
private boolean dragStarted = false;
private boolean quickZoom = false;
private boolean scrollInProgress = false;
private boolean scaleGestureOccurred = false;

MapGestureDetector(Context context, Transform transform, Projection projection, UiSettings uiSettings,
TrackingSettings trackingSettings, AnnotationManager annotationManager) {
Expand Down Expand Up @@ -111,7 +112,8 @@ boolean onTouchEvent(@NonNull MotionEvent event) {
// Handle two finger tap
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
// First pointer down
// First pointer down, reset scaleGestureOccurred, used to avoid triggering a fling after a scale gesture #7666
scaleGestureOccurred = false;
transform.setGestureInProgress(true);
break;

Expand Down Expand Up @@ -294,7 +296,9 @@ public void onLongPress(MotionEvent motionEvent) {

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (!trackingSettings.isScrollGestureCurrentlyEnabled()) {
if ((!trackingSettings.isScrollGestureCurrentlyEnabled()) || scaleGestureOccurred) {
// don't allow a fling is scroll is disabled
// and ignore when a scale gesture has occurred
return false;
}

Expand Down Expand Up @@ -368,6 +372,7 @@ public boolean onScaleBegin(ScaleGestureDetector detector) {
return false;
}

scaleGestureOccurred = true;
beginTime = detector.getEventTime();
MapboxEvent.trackGestureEvent(projection,
MapboxEvent.GESTURE_PINCH_START, detector.getFocusX(), detector.getFocusY(), transform.getZoom());
Expand Down