Skip to content

Instantly share code, notes, and snippets.

@lukelorusso
Created July 26, 2020 08:40
Show Gist options
  • Save lukelorusso/47177930e11e68526f079e8965d65a21 to your computer and use it in GitHub Desktop.
Save lukelorusso/47177930e11e68526f079e8965d65a21 to your computer and use it in GitHub Desktop.
First try: it didn't work...
fun RecyclerView.bindScrollTo(vararg destinations: RecyclerView) {
object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
}
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
// First try: it didn't work...
destinations.forEach { destinationRecyclerView ->
destinationRecyclerView.scrollBy(dx, dy)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment