Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Priyansh-Kedia/a20c99d2b0ab37637ba3456576b01b65 to your computer and use it in GitHub Desktop.
Save Priyansh-Kedia/a20c99d2b0ab37637ba3456576b01b65 to your computer and use it in GitHub Desktop.
Pagination in RecyclerView with GridLayoutManager
mediaRecycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
if ((gridLayoutManager.findLastVisibleItemPosition() == localDocumentsAdapter.itemCount - DOCUMENT_BUFFER) && dy > 0) {
documentViewModel.getImages(DOCUMENTS_COUNT)
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment