MapEventLayer: take over gesture detection after double tap
This commit is contained in:
parent
57ec6ea067
commit
4f3560d810
@ -77,24 +77,6 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
|
||||
return mLayerList.set(pIndex, pElement);
|
||||
}
|
||||
|
||||
public boolean handleMotionEvent(MotionEvent e) {
|
||||
|
||||
if (!mCancelGesture)
|
||||
if (mGestureDetector.onTouchEvent(e))
|
||||
return true;
|
||||
|
||||
if (mCancelGesture) {
|
||||
int action = e.getAction();
|
||||
if (action == MotionEvent.ACTION_CANCEL ||
|
||||
action == MotionEvent.ACTION_UP)
|
||||
mCancelGesture = false;
|
||||
}
|
||||
if (onTouchEvent(e))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean mDirtyLayers;
|
||||
private RenderOverlay[] mDrawLayers;
|
||||
|
||||
@ -163,6 +145,28 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
|
||||
|
||||
private boolean mCancelGesture;
|
||||
|
||||
public boolean handleMotionEvent(MotionEvent e) {
|
||||
boolean handleGesture = true;
|
||||
|
||||
if (mCancelGesture) {
|
||||
int action = e.getAction();
|
||||
handleGesture = (action == MotionEvent.ACTION_CANCEL ||
|
||||
action == MotionEvent.ACTION_UP);
|
||||
}
|
||||
|
||||
if (handleGesture) {
|
||||
if (mGestureDetector.onTouchEvent(e))
|
||||
return true;
|
||||
|
||||
mCancelGesture = false;
|
||||
}
|
||||
|
||||
if (onTouchEvent(e))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this to not foward events to generic GestureDetector until
|
||||
* next ACTION_UP or ACTION_CANCEL event. - Use with care for the
|
||||
@ -236,6 +240,7 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
|
||||
|
||||
@Override
|
||||
public boolean onDoubleTap(final MotionEvent e) {
|
||||
|
||||
if (mDirtyLayers)
|
||||
updateLayers();
|
||||
|
||||
@ -314,6 +319,9 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
|
||||
|
||||
@Override
|
||||
public void onLongPress(final MotionEvent pEvent) {
|
||||
if (mCancelGesture)
|
||||
return;
|
||||
|
||||
if (mDirtyLayers)
|
||||
updateLayers();
|
||||
|
||||
|
@ -253,6 +253,9 @@ public class MapEventLayer extends Overlay {
|
||||
if (debug)
|
||||
printState("onDoubleTap");
|
||||
|
||||
// avoid onLongPress
|
||||
mMapView.getOverlayManager().cancelGesture();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -291,7 +294,7 @@ public class MapEventLayer extends Overlay {
|
||||
// float move = Math.min(mMapView.getWidth(), mMapView.getHeight()) * 2 / 3;
|
||||
// mMapPosition.animateTo(vx * move, vy * move, 250);
|
||||
//} else {
|
||||
float s = (200 / mMapView.dpi);
|
||||
float s = (200 / MapView.dpi);
|
||||
|
||||
mMapPosition.animateFling(
|
||||
Math.round(velocityX * s),
|
||||
|
Loading…
x
Reference in New Issue
Block a user