Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
8cb46e19fc
2 changed files with 18 additions and 9 deletions
|
@ -33,6 +33,7 @@ public class DoubleTapScaleDetector {
|
||||||
private MotionEvent firstUp;
|
private MotionEvent firstUp;
|
||||||
private MotionEvent secondDown;
|
private MotionEvent secondDown;
|
||||||
private int mDoubleTapSlopSquare;
|
private int mDoubleTapSlopSquare;
|
||||||
|
private boolean mIsDoubleTapping;
|
||||||
|
|
||||||
public DoubleTapScaleDetector(Activity ctx, DoubleTapZoomListener listener) {
|
public DoubleTapScaleDetector(Activity ctx, DoubleTapZoomListener listener) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
@ -46,7 +47,7 @@ public class DoubleTapScaleDetector {
|
||||||
displayHeightPx = defaultDisplay.getHeight();
|
displayHeightPx = defaultDisplay.getHeight();
|
||||||
}
|
}
|
||||||
final ViewConfiguration configuration = ViewConfiguration.get(ctx);
|
final ViewConfiguration configuration = ViewConfiguration.get(ctx);
|
||||||
int doubleTapSlop = configuration.getScaledTouchSlop();
|
int doubleTapSlop = (int) (configuration.getScaledTouchSlop() * 1.5);
|
||||||
mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
|
mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,22 +57,25 @@ public class DoubleTapScaleDetector {
|
||||||
}
|
}
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||||
|
boolean handled = false;
|
||||||
if (mIsInZoomMode) {
|
if (mIsInZoomMode) {
|
||||||
secondDown = null;
|
|
||||||
mIsInZoomMode = false;
|
mIsInZoomMode = false;
|
||||||
listener.onZoomEnded(scale);
|
listener.onZoomEnded(scale);
|
||||||
return true;
|
handled = true;
|
||||||
} else {
|
} else {
|
||||||
|
firstUp = MotionEvent.obtain(event);
|
||||||
|
}
|
||||||
if (secondDown != null &&
|
if (secondDown != null &&
|
||||||
calculateSqaredDistance(secondDown, event) < mDoubleTapSlopSquare) {
|
calculateSqaredDistance(secondDown, event) < mDoubleTapSlopSquare) {
|
||||||
listener.onDoubleTap(event);
|
listener.onDoubleTap(event);
|
||||||
}
|
}
|
||||||
firstUp = MotionEvent.obtain(event);
|
|
||||||
secondDown = null;
|
secondDown = null;
|
||||||
}
|
mIsDoubleTapping = false;
|
||||||
|
return handled;
|
||||||
} else {
|
} else {
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN && !mIsInZoomMode) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN && !mIsInZoomMode) {
|
||||||
if (isConsideredDoubleTap(firstDown, firstUp, event)) {
|
if (isConsideredDoubleTap(firstDown, firstUp, event)) {
|
||||||
|
mIsDoubleTapping = true;
|
||||||
secondDown = MotionEvent.obtain(event);
|
secondDown = MotionEvent.obtain(event);
|
||||||
float x = event.getX();
|
float x = event.getX();
|
||||||
float y = event.getY();
|
float y = event.getY();
|
||||||
|
@ -101,6 +105,10 @@ public class DoubleTapScaleDetector {
|
||||||
return mIsInZoomMode;
|
return mIsInZoomMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDoubleTapping() {
|
||||||
|
return mIsDoubleTapping;
|
||||||
|
}
|
||||||
|
|
||||||
private int convertPxToDp(int px) {
|
private int convertPxToDp(int px) {
|
||||||
return Math.round(px / (Resources.getSystem().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
|
return Math.round(px / (Resources.getSystem().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
|
||||||
}
|
}
|
||||||
|
|
|
@ -843,7 +843,8 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
||||||
}
|
}
|
||||||
final boolean isMultiTouch = multiTouchSupport.onTouchEvent(event);
|
final boolean isMultiTouch = multiTouchSupport.onTouchEvent(event);
|
||||||
doubleTapScaleDetector.onTouchEvent(event);
|
doubleTapScaleDetector.onTouchEvent(event);
|
||||||
if (!isMultiTouch && !doubleTapScaleDetector.isInZoomMode()) {
|
if (!(isMultiTouch || doubleTapScaleDetector.isInZoomMode()
|
||||||
|
|| doubleTapScaleDetector.isDoubleTapping())) {
|
||||||
gestureDetector.onTouchEvent(event);
|
gestureDetector.onTouchEvent(event);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue