Skip to content

Instantly share code, notes, and snippets.

@mbakgun
Created October 11, 2020 15:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
package com.dolap.events.helper.util
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.dolap.events.helper.visibleitem.VisibleState
abstract class EndlessRecyclerViewScrollListener(private val mLinearLayoutManager: LinearLayoutManager) :
RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
val firstCompletelyVisibleItemPosition =
mLinearLayoutManager.findFirstCompletelyVisibleItemPosition()
val lastCompletelyVisibleItemPosition =
mLinearLayoutManager.findLastCompletelyVisibleItemPosition()
onVisibleItemChanged(VisibleState(firstCompletelyVisibleItemPosition,
lastCompletelyVisibleItemPosition))
}
abstract fun onVisibleItemChanged(state: VisibleState)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment