Giter Club home page Giter Club logo

genericrecyclerview's Introduction

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

genericrecyclerview's People

Contributors

janbarari avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.