Skip to content

Instantly share code, notes, and snippets.

@Alec-DeSouza
Created July 5, 2018 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alec-DeSouza/c571a1f8dc9f57e1d99a2b9877f9916c to your computer and use it in GitHub Desktop.
Save Alec-DeSouza/c571a1f8dc9f57e1d99a2b9877f9916c to your computer and use it in GitHub Desktop.
RecyclerView compatible with scrolling and ViewPager swiping
class StoppableRecyclerView(context: Context, attrs: AttributeSet?, defStyle: Int)
: RecyclerView(context, attrs, defStyle) {
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
constructor(context: Context) : this(context, null, 0)
override fun onInterceptTouchEvent(e: MotionEvent?): Boolean {
if(e?.action == MotionEvent.ACTION_DOWN) {
stopNestedScroll()
stopScroll()
}
return super.onInterceptTouchEvent(e)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment