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,
|
private final boolean isConsideredDoubleTap(MotionEvent firstDown,
|
||||||
MotionEvent firstUp,
|
MotionEvent firstUp,
|
||||||
MotionEvent secondDown) {
|
MotionEvent secondDown) {
|
||||||
if (firstDown == null || firstUp == null || secondDown == null) {
|
if (firstDown == null || firstUp == null || secondDown == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public class DoubleTapScaleDetector {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final boolean isConfirmedScale(MotionEvent secondDown,
|
private static final boolean isConfirmedScale(MotionEvent secondDown,
|
||||||
MotionEvent moveEvent) {
|
MotionEvent moveEvent) {
|
||||||
if (secondDown == null || moveEvent == null) {
|
if (secondDown == null || moveEvent == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -139,12 +139,12 @@ public class DoubleTapScaleDetector {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface DoubleTapZoomListener {
|
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();
|
animatedDraggingThread.stopAnimating();
|
||||||
}
|
}
|
||||||
for (int i = layers.size() - 1; i >= 0; i--) {
|
for (int i = layers.size() - 1; i >= 0; i--) {
|
||||||
if (layers.get(i).onTouchEvent(event, getCurrentRotatedTileBox())) {
|
layers.get(i).onTouchEvent(event, getCurrentRotatedTileBox());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!multiTouchSupport.onTouchEvent(event)) {
|
final boolean isMultiTouch = multiTouchSupport.onTouchEvent(event);
|
||||||
/* return */
|
doubleTapScaleDetector.onTouchEvent(event);
|
||||||
doubleTapScaleDetector.onTouchEvent(event);
|
if (!isMultiTouch && !doubleTapScaleDetector.isInZoomMode()) {
|
||||||
if (!doubleTapScaleDetector.isInZoomMode()) {
|
gestureDetector.onTouchEvent(event);
|
||||||
gestureDetector.onTouchEvent(event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1100,13 +1096,17 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
||||||
@Override
|
@Override
|
||||||
public boolean onDoubleTap(MotionEvent e) {
|
public boolean onDoubleTap(MotionEvent e) {
|
||||||
LOG.debug("onDoubleTap getZoom()");
|
LOG.debug("onDoubleTap getZoom()");
|
||||||
if (isZoomingAllowed(getZoom(), 1.1f)) {
|
if (!doubleTapScaleDetector.isInZoomMode()) {
|
||||||
final RotatedTileBox tb = getCurrentRotatedTileBox();
|
if (isZoomingAllowed(getZoom(), 1.1f)) {
|
||||||
final double lat = tb.getLatFromPixel(e.getX(), e.getY());
|
final RotatedTileBox tb = getCurrentRotatedTileBox();
|
||||||
final double lon = tb.getLonFromPixel(e.getX(), e.getY());
|
final double lat = tb.getLatFromPixel(e.getX(), e.getY());
|
||||||
getAnimatedDraggingThread().startMoving(lat, lon, getZoom() + 1, true);
|
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()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
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