diff --git a/OsmAnd/src/net/osmand/plus/views/MultiTouchSupport.java b/OsmAnd/src/net/osmand/plus/views/MultiTouchSupport.java index 007fe36f9b..0e36ae4089 100644 --- a/OsmAnd/src/net/osmand/plus/views/MultiTouchSupport.java +++ b/OsmAnd/src/net/osmand/plus/views/MultiTouchSupport.java @@ -88,43 +88,42 @@ public class MultiTouchSupport { if(inZoomMode){ listener.onZoomOrRotationEnded(zoomRelative, angleRelative); inZoomMode = false; - return true; + //return true; } return false; - } else if (pointCount == 2) { - Float x1 = (Float) getX.invoke(event, 0); - Float x2 = (Float) getX.invoke(event, 1); - Float y1 = (Float) getY.invoke(event, 0); - Float y2 = (Float) getY.invoke(event, 1); - float distance = (float) Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); - float angle = 0; - boolean angleDefined = false; - if(x1 != x2 || y1 != y2) { - angleDefined = true; - angle = (float) (Math.atan2(y2 - y1, x2 -x1) * 180 / Math.PI); + } + Float x1 = (Float) getX.invoke(event, 0); + Float x2 = (Float) getX.invoke(event, 1); + Float y1 = (Float) getY.invoke(event, 0); + Float y2 = (Float) getY.invoke(event, 1); + float distance = (float) Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); + float angle = 0; + boolean angleDefined = false; + if(x1 != x2 || y1 != y2) { + angleDefined = true; + angle = (float) (Math.atan2(y2 - y1, x2 -x1) * 180 / Math.PI); + } + if (actionCode == ACTION_POINTER_DOWN) { + centerPoint = new PointF((x1 + x2) / 2, (y1 + y2) / 2); + listener.onGestureInit(x1, y1, x2, y2); + listener.onZoomStarted(centerPoint); + zoomStartedDistance = distance; + angleStarted = angle; + inZoomMode = true; + return true; + } else if(actionCode == ACTION_POINTER_UP){ + if(inZoomMode){ + listener.onZoomOrRotationEnded(zoomRelative, angleRelative); + inZoomMode = false; } - if (actionCode == ACTION_POINTER_DOWN) { - centerPoint = new PointF((x1 + x2) / 2, (y1 + y2) / 2); - listener.onGestureInit(x1, y1, x2, y2); - listener.onZoomStarted(centerPoint); - zoomStartedDistance = distance; - angleStarted = angle; - inZoomMode = true; - return true; - //} else if(actionCode == ACTION_POINTER_UP){ - // if(inZoomMode){ - // listener.onZoomOrRotationEnded(zoomRelative, angleRelative); - // inZoomMode = false; - // } - // return true; - } else if(inZoomMode && actionCode == MotionEvent.ACTION_MOVE){ - if(angleDefined) { - angleRelative = MapUtils.unifyRotationTo360(angle - angleStarted); - } - zoomRelative = distance / zoomStartedDistance; - listener.onZoomingOrRotating(zoomRelative, angleRelative); - return false; + return true; + } else if(inZoomMode && actionCode == MotionEvent.ACTION_MOVE){ + if(angleDefined) { + angleRelative = MapUtils.unifyRotationTo360(angle - angleStarted); } + zoomRelative = distance / zoomStartedDistance; + listener.onZoomingOrRotating(zoomRelative, angleRelative); + return false; } } catch (Exception e) { log.debug("Multi touch exception" , e); //$NON-NLS-1$ diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index 7582d2a6d0..20d20e652e 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -862,12 +862,6 @@ public class OsmandMapTileView implements IMapDownloaderCallback { layers.get(i).onTouchEvent(event, getCurrentRotatedTileBox()); } gestureDetector.onTouchEvent(event); - } else { - MotionEvent cancelEvent = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis() + 100, MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0); - for (int i = layers.size() - 1; i >= 0; i--) { - layers.get(i).onTouchEvent(cancelEvent, getCurrentRotatedTileBox()); - } - gestureDetector.onTouchEvent(cancelEvent); } return true; }