Skip to content

Instantly share code, notes, and snippets.

@EmmanuelGuther
Created January 26, 2021 11:21
Show Gist options
  • Save EmmanuelGuther/4e1b7b6c0bed7f23c50a070bc65679a6 to your computer and use it in GitHub Desktop.
Save EmmanuelGuther/4e1b7b6c0bed7f23c50a070bc65679a6 to your computer and use it in GitHub Desktop.
fun RecyclerView.onEndScrollListener(listener:()->Unit){
this.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
if (!recyclerView.canScrollVertically(1) && newState == RecyclerView.SCROLL_STATE_IDLE) {
listener()
}
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment