test having slop distance for pinch zoom center move

This commit is contained in:
sonora 2017-01-03 12:40:32 +01:00
parent 6625215b1a
commit 1f0fdc3311

View file

@ -3,6 +3,7 @@ package net.osmand.plus.views;
import android.content.Context;
import android.graphics.PointF;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import net.osmand.PlatformUtil;
import net.osmand.util.MapUtils;
@ -77,6 +78,9 @@ public class MultiTouchSupport {
private double zoomRelative = 1;
private PointF centerPoint = new PointF();
private final int mMoveZoomCenterSlop2 = ViewConfiguration.getScaledTouchSlop() * ViewConfiguration.getScaledTouchSlop() / 4;
private boolean mScrolling = false;
public boolean onTouchEvent(MotionEvent event){
if(!isMultiTouchSupported()){
return false;
@ -88,6 +92,7 @@ public class MultiTouchSupport {
if(inZoomMode){
listener.onZoomOrRotationEnded(zoomRelative, angleRelative);
inZoomMode = false;
mScrolling = false;
return true;
}
return false;
@ -115,11 +120,17 @@ public class MultiTouchSupport {
if(inZoomMode){
listener.onZoomOrRotationEnded(zoomRelative, angleRelative);
inZoomMode = false;
mScrolling = false;
}
return true;
} else if(inZoomMode && actionCode == MotionEvent.ACTION_MOVE){
// Keep zoom center fixed or flexible
if (!mScrolling) {
mScrolling = ((centerPoint.x - (x1 + x2) / 2) * (centerPoint.x - (x1 + x2) / 2) + (centerPoint.y - (y1 + y2) / 2) * (centerPoint.y - (y1 + y2) / 2)) > mMoveZoomCenterSlop2;
}
if (mScrolling) {
centerPoint = new PointF((x1 + x2) / 2, (y1 + y2) / 2);
}
if(angleDefined) {
angleRelative = MapUtils.unifyRotationTo360(angle - angleStarted);