Skip to content

Commit

Permalink
Better gesture handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
GaidamakUA committed Jun 7, 2016
1 parent f54fa3b commit 8b24f56
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ private int convertPxToDp(int px) {
}

private final boolean isConsideredDoubleTap(MotionEvent firstDown,
MotionEvent firstUp,
MotionEvent secondDown) {
MotionEvent firstUp,
MotionEvent secondDown) {
if (firstDown == null || firstUp == null || secondDown == null) {
return false;
}
Expand All @@ -123,7 +123,7 @@ private final boolean isConsideredDoubleTap(MotionEvent firstDown,
}

private static final boolean isConfirmedScale(MotionEvent secondDown,
MotionEvent moveEvent) {
MotionEvent moveEvent) {
if (secondDown == null || moveEvent == null) {
return false;
}
Expand All @@ -139,12 +139,12 @@ public float getCenterY() {
}

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);
}
}
30 changes: 15 additions & 15 deletions OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java
Original file line number Diff line number Diff line change
Expand Up @@ -830,16 +830,12 @@ public boolean onTouchEvent(MotionEvent event) {
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;
}
Expand Down Expand Up @@ -1100,13 +1096,17 @@ public boolean onSingleTapConfirmed(MotionEvent e) {
@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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down

0 comments on commit 8b24f56

Please sign in to comment.