Double tap slide zoom implemented.

This commit is contained in:
GaidamakUA 2016-01-21 09:53:09 +02:00
parent 5b5d128ea7
commit 4f776e1e00
2 changed files with 31 additions and 31 deletions

View file

@ -14,7 +14,7 @@ import org.apache.commons.logging.Log;
public class DoubleTapScaleDetector {
private static final Log LOG = PlatformUtil.getLog(DoubleTapScaleDetector.class);
private static final int DOUBLE_TAPPING_DELTA = ViewConfiguration.getTapTimeout() + 100;
private static final int DP_PER_1X = 100;
private static final int DP_PER_1X = 200;
private final DoubleTapZoomListener listener;
protected final Context ctx;
@ -23,6 +23,7 @@ public class DoubleTapScaleDetector {
private boolean isDoubleTapping = false;
private float startX;
private float startY;
private float scale;
public DoubleTapScaleDetector(Context ctx, DoubleTapZoomListener listener) {
this.ctx = ctx;
@ -37,7 +38,7 @@ public class DoubleTapScaleDetector {
if (event.getAction() == MotionEvent.ACTION_UP) {
if (isDoubleTapping) {
isDoubleTapping = false;
listener.onZoomEnded(1, 0);
listener.onZoomEnded(scale, 0);
return true;
} else {
startTime = currentTime;
@ -55,7 +56,7 @@ public class DoubleTapScaleDetector {
if (isDoubleTapping) {
float delta = convertPxToDp((int) (startY - event.getY()));
float scaleDelta = delta / DP_PER_1X;
float scale = 1 - scaleDelta;
scale = 1 - scaleDelta;
listener.onZoomingOrRotating(scale, 0);
return true;
} else {

View file

@ -269,7 +269,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
public synchronized void removeAllLayers() {
while(layers.size() > 0) {
while (layers.size() > 0) {
removeLayer(layers.get(0));
}
}
@ -481,7 +481,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
private void refreshMapInternal(DrawSettings drawSettings) {
if(view == null) {
if (view == null) {
return;
}
final float ratioy = mapPosition == OsmandSettings.BOTTOM_CONSTANT ? 0.85f : 0.5f;
@ -544,7 +544,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
@SuppressLint("WrongCall")
public void drawOverMap(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
if(mapRenderer == null) {
if (mapRenderer == null) {
fillCanvas(canvas, drawSettings);
}
final QuadPoint c = tileBox.getCenterPixelPoint();
@ -565,7 +565,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
if (!layer.drawInScreenPixels()) {
canvas.rotate(tileBox.getRotate(), c.x, c.y);
}
if(mapRenderer != null) {
if (mapRenderer != null) {
layer.onPrepareBufferImage(canvas, tileBox, drawSettings);
}
layer.onDraw(canvas, tileBox, drawSettings);
@ -576,7 +576,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
if (showMapPosition || animatedDraggingThread.isAnimatingZoom()) {
drawMapPosition(canvas, c.x, c.y);
} else if(multiTouchSupport.isInZoomMode() || doubleTapScaleDetector.isInZoomMode()) {
} else if (multiTouchSupport.isInZoomMode() || doubleTapScaleDetector.isInZoomMode()) {
drawMapPosition(canvas, multiTouchSupport.getCenterPoint().x, multiTouchSupport.getCenterPoint().y);
}
}
@ -587,7 +587,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
private void refreshBufferImage(final DrawSettings drawSettings) {
if(mapRenderer != null) {
if (mapRenderer != null) {
return;
}
if (!baseHandler.hasMessages(BASE_REFRESH_MESSAGE) || drawSettings.isUpdateVectorRendering()) {
@ -770,12 +770,11 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
return true;
}
}
if (!doubleTapScaleDetector.onTouchEvent(event)) {
if (!multiTouchSupport.onTouchEvent(event)) {
/* return */
doubleTapScaleDetector.onTouchEvent(event);
gestureDetector.onTouchEvent(event);
}
}
return true;
}
@ -908,13 +907,13 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
final LatLon r = calc.getLatLonFromPixel(cp.x + dx, cp.y + dy);
setLatLon(r.getLatitude(), r.getLongitude());
int baseZoom = initialViewport.getZoom();
while(initialViewport.getZoomFloatPart() + dz > 1) {
dz --;
baseZoom ++;
while (initialViewport.getZoomFloatPart() + dz > 1) {
dz--;
baseZoom++;
}
while(initialViewport.getZoomFloatPart() + dz < 0) {
dz ++;
baseZoom --;
while (initialViewport.getZoomFloatPart() + dz < 0) {
dz++;
baseZoom--;
}
zoomToAnimate(baseZoom, dz, true);
rotateToAnimate(calcRotate);