Very simple use android recyclerView adapter and endlessScrolled in android support library recyclerView
- Manage Loading and Error Layout in The List Row
- Ability add custom layout in progress pagination and default layout
- Support linear, Grid, StaggeredGrid LayoutManger for endless
- Clean to uses
implementation 'androidx.recyclerview:recyclerview:$VERSION'
implementation 'io.github.farshidroohi:customAdapterRecycleView:2.1.4'
class MyAdapter : AdapterRecyclerView<String?>(R.layout.my_item, R.layout.progress_view, R.layout.item_error,R.id.btnTrayAgain) {
override fun onBindView(viewHolder: ItemViewHolder, position: Int, context: Context, element: String?) {
val binding = MyItemBinding.bind(viewHolder.itemView)
binding.myTitle.text = element
}
}
android {
...
buildFeatures {
viewBinding = true
}
}
Sample Single View Type Adapter Code:
class MyAdapter : AdapterRecyclerView<String?>(
R.layout.my_item,
R.layout.progress_view,
R.layout.item_error,
R.id.btnTrayAgain
) {
override fun onBindView(
viewHolder: RecyclerView.ViewHolder,
position: Int,
context: Context,
element: String?
) {
val binding = MyItemBinding.bind(viewHolder.itemView)
binding.txtTitle.text = element
}
}
Sample Use Adapter:
val myAdapter = MyAdapter()
myAdapter.onRetryClicked = {
// onClick Error Button
}
recyclerView.onLoadMoreListener {
// set onLoad More Listener for Pagination
}
recyclerView.onItemClickListener(
onClickItem = { position ->
// OnClick Item
}, onLongClickItem = { position ->
// OnLong Click Item
})
Multi View Type Sample: Code