Skip to content

Instantly share code, notes, and snippets.

@TorkelV
Created February 24, 2021 12:12
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 TorkelV/2ef4d965281c19ffd2132351c8178707 to your computer and use it in GitHub Desktop.
Save TorkelV/2ef4d965281c19ffd2132351c8178707 to your computer and use it in GitHub Desktop.
val lm = binding.recyclerView.layoutManager as LinearLayoutManager
binding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
val lastVisible = lm.findLastVisibleItemPosition() + 1
if (viewModel.lastVisibleItem.value < lastVisible) {
viewModel.lastVisibleItem.value = lastVisible
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment