Skip to content

A simplified easy to use a smart recyclerview and adapter to create dynamic content list like youtube, google play, Netflix

License

Notifications You must be signed in to change notification settings

vzulauf67/GenericRecyclerView

 
 

Repository files navigation

GenericRecyclerView

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

Installation

allprojects {
	repositories {
		maven { url 'https://jitpack.io' }
	}
}
dependencies {
    implementation 'com.github.janbarari:GenericRecyclerView:1.0.0-alpha'
}

Setup

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

Also you can use GenericRecyclerView which have lazy load feature (Simplified LoadMore Function)

genericRecyclerView.setLoadMoreListener(object: GenericRecyclerView.GenericRecyclerViewListener {
    override fun onLoadMore() {}
})

Proguard-rule Configuration

-keepclasseswithmembers class * extends io.github.janbarari.genericrecyclerview.viewholder.GenericViewHolder { *; }
-keepclasseswithmembers class io.github.janbarari.genericrecyclerview.* { *; }

If you like it, please tap the Star(⭐️) button

About

A simplified easy to use a smart recyclerview and adapter to create dynamic content list like youtube, google play, Netflix

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 92.4%
  • Java 7.6%