Created
February 24, 2021 12:12
-
-
Save TorkelV/2ef4d965281c19ffd2132351c8178707 to your computer and use it in GitHub Desktop.
This file contains 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
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