Created
November 15, 2020 14:12
-
-
Save vshkl/08cebff7e916f4da01227caeffbc576a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainSimpleOnItemTouchListener( | |
private val listener: OnInterceptTouchEventListener | |
) : RecyclerView.SimpleOnItemTouchListener() { | |
interface OnInterceptTouchEventListener { | |
fun onInterceptTouchEvent(touchedPosition: Int) | |
} | |
override fun onInterceptTouchEvent(recyclerView: RecyclerView, event: MotionEvent): Boolean { | |
val childView = recyclerView.findChildViewUnder(event.x, event.y) | |
val touchedPosition = childView?.let { recyclerView.getChildAdapterPosition(childView) } ?: -1 | |
listener.onInterceptTouchEvent(touchedPosition) | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment