Created
July 26, 2020 08:40
-
-
Save lukelorusso/47177930e11e68526f079e8965d65a21 to your computer and use it in GitHub Desktop.
First try: it didn't work...
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
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