Skip to content

Instantly share code, notes, and snippets.

@mbakgun
Created October 11, 2020 15:57
Show Gist options
  • Select an option

  • Save mbakgun/6ce1a7213cf857738df53b7e0ec2aba5 to your computer and use it in GitHub Desktop.

Select an option

Save mbakgun/6ce1a7213cf857738df53b7e0ec2aba5 to your computer and use it in GitHub Desktop.
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