test having slop distance for pinch zoom center move
This commit is contained in:
parent
6625215b1a
commit
1f0fdc3311
1 changed files with 12 additions and 1 deletions
|
@ -3,6 +3,7 @@ package net.osmand.plus.views;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
import android.view.ViewConfiguration;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
@ -77,6 +78,9 @@ public class MultiTouchSupport {
|
||||||
private double zoomRelative = 1;
|
private double zoomRelative = 1;
|
||||||
private PointF centerPoint = new PointF();
|
private PointF centerPoint = new PointF();
|
||||||
|
|
||||||
|
private final int mMoveZoomCenterSlop2 = ViewConfiguration.getScaledTouchSlop() * ViewConfiguration.getScaledTouchSlop() / 4;
|
||||||
|
private boolean mScrolling = false;
|
||||||
|
|
||||||
public boolean onTouchEvent(MotionEvent event){
|
public boolean onTouchEvent(MotionEvent event){
|
||||||
if(!isMultiTouchSupported()){
|
if(!isMultiTouchSupported()){
|
||||||
return false;
|
return false;
|
||||||
|
@ -88,6 +92,7 @@ public class MultiTouchSupport {
|
||||||
if(inZoomMode){
|
if(inZoomMode){
|
||||||
listener.onZoomOrRotationEnded(zoomRelative, angleRelative);
|
listener.onZoomOrRotationEnded(zoomRelative, angleRelative);
|
||||||
inZoomMode = false;
|
inZoomMode = false;
|
||||||
|
mScrolling = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -115,11 +120,17 @@ public class MultiTouchSupport {
|
||||||
if(inZoomMode){
|
if(inZoomMode){
|
||||||
listener.onZoomOrRotationEnded(zoomRelative, angleRelative);
|
listener.onZoomOrRotationEnded(zoomRelative, angleRelative);
|
||||||
inZoomMode = false;
|
inZoomMode = false;
|
||||||
|
mScrolling = false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if(inZoomMode && actionCode == MotionEvent.ACTION_MOVE){
|
} else if(inZoomMode && actionCode == MotionEvent.ACTION_MOVE){
|
||||||
// Keep zoom center fixed or flexible
|
// 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);
|
centerPoint = new PointF((x1 + x2) / 2, (y1 + y2) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
if(angleDefined) {
|
if(angleDefined) {
|
||||||
angleRelative = MapUtils.unifyRotationTo360(angle - angleStarted);
|
angleRelative = MapUtils.unifyRotationTo360(angle - angleStarted);
|
||||||
|
|
Loading…
Reference in a new issue