解决方案:
在onTouchEvent的每个事件打上日志,发现监听不到MotionEvent.ACTION_UP的情况下,却监听到了MotionEvent.ACTION_CANCEL,所以让监听到MotionEvent.ACTION_CANCEL的时候,同样执行Up的操作即可。
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
//持ち上げる
isSelected = false
//クリックとして300ミリ秒未満
if (System.currentTimeMillis() - lastTimeStamp <= 300) {
listener!!.onClick()
}
isPress = false
}