Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f66e0e3edf
1 changed files with 12 additions and 1 deletions
|
@ -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
|
||||
centerPoint = new PointF((x1 + x2) / 2, (y1 + y2) / 2);
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue