1.快速連點判斷(1s)
private fun isFastDoubleClick(): Boolean {
val time = System.currentTimeMillis()
val timeD: Long = time - lastClickTime
return if (timeD in 0..1000) {
true
} else {
lastClickTime = time
false
}
}
2.覆寫dispatchTouchEvent
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
if(ev?.action == MotionEvent.ACTION_DOWN) {
if (isFastDoubleClick()) {
return true
}
}
return super.dispatchTouchEvent(ev)
}