reset gesture state on ActionDown instead of ActionUp
-> this should help when up event was consumed by overlay
This commit is contained in:
parent
3d79c3ea2e
commit
8a808265a5
@ -25,6 +25,9 @@ import android.view.MotionEvent;
|
|||||||
*
|
*
|
||||||
* @TODO:
|
* @TODO:
|
||||||
* - better recognition of tilt/rotate/scale state
|
* - better recognition of tilt/rotate/scale state
|
||||||
|
* one could check change of rotation / scale within a
|
||||||
|
* given time to estimate if the mode should be changed:
|
||||||
|
* http://en.wikipedia.org/wiki/Viterbi_algorithm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MapEventLayer extends Overlay {
|
public class MapEventLayer extends Overlay {
|
||||||
@ -38,6 +41,7 @@ public class MapEventLayer extends Overlay {
|
|||||||
private boolean mBeginRotate;
|
private boolean mBeginRotate;
|
||||||
private boolean mBeginTilt;
|
private boolean mBeginTilt;
|
||||||
private boolean mDoubleTap;
|
private boolean mDoubleTap;
|
||||||
|
private boolean mWasMulti;
|
||||||
|
|
||||||
private float mPrevX;
|
private float mPrevX;
|
||||||
private float mPrevY;
|
private float mPrevY;
|
||||||
@ -69,37 +73,29 @@ public class MapEventLayer extends Overlay {
|
|||||||
int action = getAction(e);
|
int action = getAction(e);
|
||||||
|
|
||||||
if (action == MotionEvent.ACTION_DOWN) {
|
if (action == MotionEvent.ACTION_DOWN) {
|
||||||
mMulti = 0;
|
mBeginRotate = false;
|
||||||
|
mBeginTilt = false;
|
||||||
|
mBeginScale = false;
|
||||||
|
mDoubleTap = false;
|
||||||
mWasMulti = false;
|
mWasMulti = false;
|
||||||
|
|
||||||
mPrevX = e.getX(0);
|
mPrevX = e.getX(0);
|
||||||
mPrevY = e.getY(0);
|
mPrevY = e.getY(0);
|
||||||
return true; //onActionDown(e);
|
return true; //onActionDown(e);
|
||||||
} else if (action == MotionEvent.ACTION_MOVE) {
|
} else if (action == MotionEvent.ACTION_MOVE) {
|
||||||
return onActionMove(e);
|
return onActionMove(e);
|
||||||
} else if (action == MotionEvent.ACTION_UP) {
|
} else if (action == MotionEvent.ACTION_UP) {
|
||||||
mBeginRotate = false;
|
|
||||||
mBeginTilt = false;
|
|
||||||
mBeginScale = false;
|
|
||||||
mDoubleTap = false;
|
|
||||||
return true;
|
return true;
|
||||||
//return onActionUp(e);
|
|
||||||
|
|
||||||
} else if (action == MotionEvent.ACTION_CANCEL) {
|
} else if (action == MotionEvent.ACTION_CANCEL) {
|
||||||
mDoubleTap = false;
|
mDoubleTap = false;
|
||||||
return true;
|
return true;
|
||||||
//return onActionCancel();
|
|
||||||
} else if (action == MotionEvent.ACTION_POINTER_DOWN) {
|
} else if (action == MotionEvent.ACTION_POINTER_DOWN) {
|
||||||
mMulti++;
|
|
||||||
mWasMulti = true;
|
mWasMulti = true;
|
||||||
|
|
||||||
updateMulti(e);
|
updateMulti(e);
|
||||||
return true;
|
return true;
|
||||||
//return onActionPointerDown(e);
|
|
||||||
} else if (action == MotionEvent.ACTION_POINTER_UP) {
|
} else if (action == MotionEvent.ACTION_POINTER_UP) {
|
||||||
updateMulti(e);
|
updateMulti(e);
|
||||||
mMulti--;
|
|
||||||
return true;
|
return true;
|
||||||
//return onActionPointerUp(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -138,14 +134,6 @@ public class MapEventLayer extends Overlay {
|
|||||||
if (e.getPointerCount() < 2)
|
if (e.getPointerCount() < 2)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (mMulti == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// TODO improve gesture recognition,
|
|
||||||
// one could check change of rotation / scale within a
|
|
||||||
// given time to estimate if the mode should be changed:
|
|
||||||
// http://en.wikipedia.org/wiki/Viterbi_algorithm
|
|
||||||
|
|
||||||
float x2 = e.getX(1);
|
float x2 = e.getX(1);
|
||||||
float y2 = e.getY(1);
|
float y2 = e.getY(1);
|
||||||
|
|
||||||
@ -238,9 +226,6 @@ public class MapEventLayer extends Overlay {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int mMulti;
|
|
||||||
private boolean mWasMulti;
|
|
||||||
|
|
||||||
private void updateMulti(MotionEvent e) {
|
private void updateMulti(MotionEvent e) {
|
||||||
int cnt = e.getPointerCount();
|
int cnt = e.getPointerCount();
|
||||||
|
|
||||||
@ -275,9 +260,7 @@ public class MapEventLayer extends Overlay {
|
|||||||
public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX,
|
public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX,
|
||||||
final float distanceY) {
|
final float distanceY) {
|
||||||
|
|
||||||
if (mMulti == 0) {
|
if (e2.getPointerCount() == 1) {
|
||||||
if (debug)
|
|
||||||
printState("onScroll " + distanceX + " " + distanceY);
|
|
||||||
mMapPosition.moveMap(-distanceX, -distanceY);
|
mMapPosition.moveMap(-distanceX, -distanceY);
|
||||||
mMapView.redrawMap(true);
|
mMapView.redrawMap(true);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user