Program: 86969
Project: 86969
Buggy source:
@Override public boolean onTouch(View v,MotionEvent event){
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
    last1MoveX=event.getRawX();
  last1MoveY=event.getRawY();
downRawX=event.getRawX();
downRawY=event.getRawY();
downTime=new Date().getTime();
directionKnown=false;
break;
case MotionEvent.ACTION_MOVE:
last2MoveX=last1MoveX;
last2MoveY=last1MoveY;
last1MoveX=event.getRawX();
last1MoveY=event.getRawY();
last2MoveTime=last1MoveTime;
last1MoveTime=new Date().getTime();
if (!directionKnown) {
if (downRawY - event.getRawY() > MIN_SWIPE_DIST) {
directionKnown=true;
direction=DIRECTION_UP;
Log.d(LOG_TAG,"String_Node_Str");
}
 else if (downRawY - event.getRawY() < -MIN_SWIPE_DIST) {
directionKnown=true;
direction=DIRECTION_DOWN;
Log.d(LOG_TAG,"String_Node_Str");
}
 else if (downRawX - event.getRawX() > MIN_SWIPE_DIST) {
directionKnown=true;
direction=DIRECTION_LEFT;
Log.d(LOG_TAG,"String_Node_Str");
}
 else if (downRawX - event.getRawX() < -MIN_SWIPE_DIST) {
directionKnown=true;
direction=DIRECTION_RIGHT;
Log.d(LOG_TAG,"String_Node_Str");
}
}
 else {
onMove(event,direction,downRawX,downRawY);
}
break;
case MotionEvent.ACTION_UP:
upRawX=event.getRawX();
upRawY=event.getRawY();
Log.d(LOG_TAG,"String_Node_Str" + upRawX + "String_Node_Str"+ upRawY);
upTime=new Date().getTime();
distX=convertPxToDip((int)(upRawX - downRawX));
distY=convertPxToDip((int)(upRawY - downRawY));
velocityX=distX / ((upTime - downTime) / 1000.0f);
velocityY=distY / ((upTime - downTime) / 1000.0f);
float endVelocityX;
if (last2MoveX > 0) {
endVelocityX=(event.getRawX() - last2MoveX) / (upTime - last2MoveTime);
}
 else {
endVelocityX=velocityX;
}
float endVelocityY;
if (last2MoveY > 0) {
endVelocityY=(event.getRawY() - last2MoveY) / (upTime - last2MoveTime);
}
 else {
endVelocityY=velocityY;
}
if (directionKnown) {
if (direction == DIRECTION_UP && velocityY < -MIN_THRESHOLD_VELOCITY) {
Log.d(LOG_TAG,"String_Node_Str");
onBottomToTop(-endVelocityY);
}
 else if (direction == DIRECTION_DOWN && velocityY > MIN_THRESHOLD_VELOCITY) {
Log.d(LOG_TAG,"String_Node_Str");
onTopToBottom(endVelocityY);
}
 else if (direction == DIRECTION_LEFT && velocityX < -MIN_THRESHOLD_VELOCITY) {
Log.d(LOG_TAG,"String_Node_Str");
onRightToLeft(-endVelocityX);
}
 else if (direction == DIRECTION_RIGHT && velocityX > MIN_THRESHOLD_VELOCITY) {
Log.d(LOG_TAG,"String_Node_Str");
onLeftToRight(endVelocityX);
}
 else {
Log.d(LOG_TAG,"String_Node_Str" + velocityX + "String_Node_Str"+ velocityY);
onSwipeFail();
}
}
 else {
onDirectionUnknown();
}
break;
}
return true;
}

Fixed version (ground truth):
@Override public boolean onTouch(View v,MotionEvent event){
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
    last1MoveX=event.getRawX();
  last1MoveY=event.getRawY();
downRawX=event.getRawX();
downRawY=event.getRawY();
downTime=new Date().getTime();
directionKnown=false;
break;
case MotionEvent.ACTION_MOVE:
last2MoveX=last1MoveX;
last2MoveY=last1MoveY;
last1MoveX=event.getRawX();
last1MoveY=event.getRawY();
last2MoveTime=last1MoveTime;
last1MoveTime=new Date().getTime();
if (!directionKnown) {
if (downRawY - event.getRawY() > MIN_SWIPE_DIST) {
directionKnown=true;
direction=DIRECTION_UP;
Log.d(LOG_TAG,"String_Node_Str");
}
 else if (downRawY - event.getRawY() < -MIN_SWIPE_DIST) {
directionKnown=true;
direction=DIRECTION_DOWN;
Log.d(LOG_TAG,"String_Node_Str");
}
 else if (downRawX - event.getRawX() > MIN_SWIPE_DIST) {
directionKnown=true;
direction=DIRECTION_LEFT;
Log.d(LOG_TAG,"String_Node_Str");
}
 else if (downRawX - event.getRawX() < -MIN_SWIPE_DIST) {
directionKnown=true;
direction=DIRECTION_RIGHT;
Log.d(LOG_TAG,"String_Node_Str");
}
}
 else {
onMove(event,direction,downRawX,downRawY);
}
break;
case MotionEvent.ACTION_UP:
upRawX=event.getRawX();
upRawY=event.getRawY();
Log.d(LOG_TAG,"String_Node_Str" + upRawX + "String_Node_Str"+ upRawY);
upTime=new Date().getTime();
distX=convertPxToDip((int)(upRawX - downRawX));
distY=convertPxToDip((int)(upRawY - downRawY));
velocityX=distX / ((upTime - downTime) / 1000.0f);
velocityY=distY / ((upTime - downTime) / 1000.0f);
float endVelocityX;
if (last1MoveX != upRawX) {
endVelocityX=(upRawX - last1MoveX) / (upTime - last1MoveTime);
}
 else if (last2MoveX != upRawX) {
endVelocityX=(upRawX - last2MoveX) / (upTime - last2MoveTime);
}
 else {
endVelocityX=velocityX;
}
float endVelocityY;
if (last1MoveY != upRawY) {
endVelocityY=(upRawY - last1MoveY) / (upTime - last1MoveTime);
}
 else if (last2MoveX != upRawX) {
endVelocityY=(upRawY - last2MoveY) / (upTime - last2MoveTime);
}
 else {
endVelocityY=velocityY;
}
if (directionKnown) {
if (direction == DIRECTION_UP && velocityY < -MIN_THRESHOLD_VELOCITY) {
Log.d(LOG_TAG,"String_Node_Str");
onBottomToTop(-endVelocityY);
}
 else if (direction == DIRECTION_DOWN && velocityY > MIN_THRESHOLD_VELOCITY) {
Log.d(LOG_TAG,"String_Node_Str");
onTopToBottom(endVelocityY);
}
 else if (direction == DIRECTION_LEFT && velocityX < -MIN_THRESHOLD_VELOCITY) {
Log.d(LOG_TAG,"String_Node_Str");
onRightToLeft(-endVelocityX);
}
 else if (direction == DIRECTION_RIGHT && velocityX > MIN_THRESHOLD_VELOCITY) {
Log.d(LOG_TAG,"String_Node_Str");
onLeftToRight(endVelocityX);
}
 else {
Log.d(LOG_TAG,"String_Node_Str" + velocityX + "String_Node_Str"+ velocityY);
onSwipeFail();
}
}
 else {
onDirectionUnknown();
}
break;
}
return true;
}