With this library you only focus on your list item's, creating a recyclerview with multiple view is not easy, so you can trust this library. GenericRecyclerView is a smart light-weight recyclerview and adapter to simplify working with multiple view's in list and load more feature
- Lazy load feature
- multiple viewholder support
- less code more flexibility
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.janbarari:GenericRecyclerView:1.0.0-alpha'
}
Create your viewHolders that extends GenericViewHolder
class ImageViewHolder(private val itemView: View,
private val listener: GenericUriListener): GenericViewHolder(itemView, listener) {
override fun bind(dataModel: GenericViewModel) {
val data: ImageViewModel = dataModel as ImageViewModel
//for invoke event use the listener
//listener.onClick(Any?)
}
}
Create your viewModels that extends GenericViewModel
class ImageViewModel: GenericViewModel() {}
Create your layouts
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@drawable/ic_launcher_background"/>
Create your data list + instance of GenericAdapter and initialize them
val content: ArrayList<GenericViewModel> = arrayListOf()
content.add(ImageViewModel())
val adapter = GenericAdapter(context, content, object: GenericUriListener{
override fun onClick(event: Any) {}
})
Add your ViewHolder, ViewModel, LayoutId to GenericAdapter
adapter.addView(ImageViewHolder::class.java, ImageViewModel::class.java, R.layout.grv_image_item)
Set your Recyclerview adapter to GenericAdapter
recyclerview.adapter = adapter
genericRecyclerView.setLoadMoreListener(object: GenericRecyclerView.GenericRecyclerViewListener {
override fun onLoadMore() {}
})
-keepclasseswithmembers class * extends io.github.janbarari.genericrecyclerview.viewholder.GenericViewHolder { *; }
-keepclasseswithmembers class io.github.janbarari.genericrecyclerview.* { *; }