package com.example.avi.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.view.MotionEvent;
import android.view.GestureDetector;
public class MainActivity extends AppCompatActivity implements
GestureDetector.OnGestureListener,
GestureDetector.OnDoubleTapListener{
private TextView myText;
private GestureDetector gestureDetector;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myText = (TextView) findViewById(R.id.myText);
this.gestureDetector = new GestureDetector(this, this);
gestureDetector.setOnDoubleTapListener(this);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
this.gestureDetector.onTouchEvent(event);
return super.onTouchEvent(event);
}
@Override
public boolean onSingleTapConfirmed (MotionEvent e){
myText.setText("onSingleTapConfirmed");
return false;
}
@Override
public boolean onDoubleTap (MotionEvent e){
myText.setText("onDoubleTap");
return false;
}
@Override
public boolean onDoubleTapEvent (MotionEvent e){
myText.setText("onDoubleTapEvent");
return false;
}
@Override
public boolean onDown (MotionEvent e){
myText.setText("onDown");
return false;
}
@Override
public void onShowPress (MotionEvent e){
myText.setText("onShowPress");
}
@Override
public boolean onSingleTapUp (MotionEvent e){
myText.setText("onSingleTapUp");
return false;
}
@Override
public boolean onScroll (MotionEvent e1, MotionEvent e2,float distanceX, float distanceY){
myText.setText("onScroll");
return false;
}
@Override
public void onLongPress (MotionEvent e){
myText.setText("onLongPress");
}
@Override
public boolean onFling (MotionEvent e1, MotionEvent e2,float velocityX, float velocityY){
myText.setText("onFling");
return false;
}
}