I've been playing around with motion event and drags (so I'm not lifting my finger off the screen - it's not a fling). The problem is that it only detects the second, third, forth and so on, drags moving down or up when my finger moves past the point of where the up drag or down drag starts and ends.
See code below. Count equals 2 when I drag up and 1 when I drag down. However, it only counts when, for example, I move my finger up (count 2) and then back down past the point of when I started moving up ( which will be count 1), not before that which would equal 2, and this continues as I move back up it counts 2 only when I move past the point of when I changed direction to go back down. But why doesn't it recognise it as a drag before those points, because any movement in those directions should be a drag. How do I resolve this?
Here's my simple code to test it:
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
oldX = (int) event.getRawX();
oldY = (int) event.getRawY();
break;
case MotionEvent.ACTION_MOVE:
posY = (int) event.getRawY();
posX = (int) event.getRawX();
diffPosY = posY - oldY;
diffPosX = posX - oldX;
if (diffPosY > 0){//down
count = 1;
}
else//up
{
count = 2;
}
break;