Created
October 24, 2013 15:35
-
-
Save mvberg/7139423 to your computer and use it in GitHub Desktop.
Stop PTR ListView from eating horizontal swipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onInterceptTouchEvent(MotionEvent ev) { | |
switch (ev.getAction()) { | |
case MotionEvent.ACTION_DOWN: | |
xDistance = yDistance = 0f; | |
lastX = ev.getX(); | |
lastY = ev.getY(); | |
break; | |
case MotionEvent.ACTION_MOVE: | |
final float curX = ev.getX(); | |
final float curY = ev.getY(); | |
xDistance += Math.abs(curX - lastX); | |
yDistance += Math.abs(curY - lastY); | |
lastX = curX; | |
lastY = curY; | |
// check x vs y swipe distance here | |
if(xDistance > yDistance) | |
return false; | |
} | |
return super.onInterceptTouchEvent(ev); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment