A Custom TouchListener that detects gesture operations, currently supporting the following operations:
- single tap
- double tap
- long press
- drag
- two-finger operations
view.setOnTouchListener(
object : GestureListener() {
override fun onStart(event: MotionEvent): Boolean = true
override fun onFinish(event: MotionEvent) {}
override fun onClick(event: MotionEvent) {
// onClick
}
override fun onLongClick(event: MotionEvent) {
// onLongClick
}
override fun onDoubleTap(event: MotionEvent) {
// onDoubleTap
}
override fun onDrag(event: MotionEvent, dx: Float, dy: Float) {
// onDrag
}
override fun onGesture(
event: MotionEvent,
ds: Float,
dr: Float,
dx: Float,
dy: Float,
centerPoint: PointF
) {
// onGesture
}
}
)