Better gesture handling.
This commit is contained in:
parent
f54fa3bc62
commit
8b24f5684b
3 changed files with 23 additions and 23 deletions
|
@ -101,8 +101,8 @@ public class DoubleTapScaleDetector {
|
|||
}
|
||||
|
||||
private final boolean isConsideredDoubleTap(MotionEvent firstDown,
|
||||
MotionEvent firstUp,
|
||||
MotionEvent secondDown) {
|
||||
MotionEvent firstUp,
|
||||
MotionEvent secondDown) {
|
||||
if (firstDown == null || firstUp == null || secondDown == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class DoubleTapScaleDetector {
|
|||
}
|
||||
|
||||
private static final boolean isConfirmedScale(MotionEvent secondDown,
|
||||
MotionEvent moveEvent) {
|
||||
MotionEvent moveEvent) {
|
||||
if (secondDown == null || moveEvent == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -139,12 +139,12 @@ public class DoubleTapScaleDetector {
|
|||
}
|
||||
|
||||
public interface DoubleTapZoomListener {
|
||||
public void onZoomStarted(PointF centerPoint);
|
||||
void onZoomStarted(PointF centerPoint);
|
||||
|
||||
public void onZooming(double relativeToStart);
|
||||
void onZooming(double relativeToStart);
|
||||
|
||||
public void onZoomEnded(double relativeToStart);
|
||||
void onZoomEnded(double relativeToStart);
|
||||
|
||||
public void onGestureInit(float x1, float y1, float x2, float y2);
|
||||
void onGestureInit(float x1, float y1, float x2, float y2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -830,16 +830,12 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
animatedDraggingThread.stopAnimating();
|
||||
}
|
||||
for (int i = layers.size() - 1; i >= 0; i--) {
|
||||
if (layers.get(i).onTouchEvent(event, getCurrentRotatedTileBox())) {
|
||||
return true;
|
||||
}
|
||||
layers.get(i).onTouchEvent(event, getCurrentRotatedTileBox());
|
||||
}
|
||||
if (!multiTouchSupport.onTouchEvent(event)) {
|
||||
/* return */
|
||||
doubleTapScaleDetector.onTouchEvent(event);
|
||||
if (!doubleTapScaleDetector.isInZoomMode()) {
|
||||
gestureDetector.onTouchEvent(event);
|
||||
}
|
||||
final boolean isMultiTouch = multiTouchSupport.onTouchEvent(event);
|
||||
doubleTapScaleDetector.onTouchEvent(event);
|
||||
if (!isMultiTouch && !doubleTapScaleDetector.isInZoomMode()) {
|
||||
gestureDetector.onTouchEvent(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1100,13 +1096,17 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
@Override
|
||||
public boolean onDoubleTap(MotionEvent e) {
|
||||
LOG.debug("onDoubleTap getZoom()");
|
||||
if (isZoomingAllowed(getZoom(), 1.1f)) {
|
||||
final RotatedTileBox tb = getCurrentRotatedTileBox();
|
||||
final double lat = tb.getLatFromPixel(e.getX(), e.getY());
|
||||
final double lon = tb.getLonFromPixel(e.getX(), e.getY());
|
||||
getAnimatedDraggingThread().startMoving(lat, lon, getZoom() + 1, true);
|
||||
if (!doubleTapScaleDetector.isInZoomMode()) {
|
||||
if (isZoomingAllowed(getZoom(), 1.1f)) {
|
||||
final RotatedTileBox tb = getCurrentRotatedTileBox();
|
||||
final double lat = tb.getLatFromPixel(e.getX(), e.getY());
|
||||
final double lon = tb.getLonFromPixel(e.getX(), e.getY());
|
||||
getAnimatedDraggingThread().startMoving(lat, lon, getZoom() + 1, true);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ buildscript {
|
|||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.1.0'
|
||||
classpath 'com.android.tools.build:gradle:2.1.2'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue