Skip to content

Commit

Permalink
Cancel thumb view touches with ACTION_CANCEL (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
DSteve595 authored Sep 20, 2019
1 parent 50e9ca6 commit 5db661b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class FastScrollerView @JvmOverloads constructor(
override fun onTouchEvent(event: MotionEvent): Boolean {
fun View.containsY(y: Int) = y in (top until bottom)

if (event.action == MotionEvent.ACTION_UP) {
if (event.action in MOTIONEVENT_STOP_ACTIONS) {
isPressed = false
lastSelectedPosition = null
onItemIndicatorTouched?.invoke(false)
Expand Down Expand Up @@ -347,6 +347,11 @@ class FastScrollerView @JvmOverloads constructor(

companion object {

private val MOTIONEVENT_STOP_ACTIONS = intArrayOf(
MotionEvent.ACTION_UP,
MotionEvent.ACTION_CANCEL
)

private fun FastScrollerView.createAdapterDataObserver(): RecyclerView.AdapterDataObserver {
return object : RecyclerView.AdapterDataObserver() {
override fun onChanged() {
Expand Down

0 comments on commit 5db661b

Please sign in to comment.