Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓
Working

Baset Esmaeili BasetEsmaeili

🤓
Working
View GitHub Profile
@BasetEsmaeili
BasetEsmaeili / InfiniteScrollExtensions.kt
Last active Jan 3, 2021
Add Infinite Scroll to RecyclerView
View InfiniteScrollExtensions.kt
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
fun RecyclerView.attachInfiniteScroll(onLoadMoreListener: OnLoadMoreListener) {
if (layoutManager != null)
setInfiniteScrollGrid(this, layoutManager!!, onLoadMoreListener)
else throw RuntimeException("Layout Manager is Not Set")
}