/AndroidEasyList

A data-driven RecyclerView framework for building fast and flexible lists

Primary LanguageKotlinMIT LicenseMIT

AndroidEasyList

Framework to simplify the setup and configuration of Recyclerview adapter. It allows a type-safe setup of RecyclerView adapter. also provides out-of-the-box diffing and animated deletions, inserts, moves and changes.

Everything you need to implement your own lists:

  • Easy to use RecyclerView
  • Diffable
  • Header and footer
  • Pagination
  • Collapsiple
  • Loading footer
  • Empty View
  • Filterable
  • Multiple data type

animation expandable filtering message layout pagination sectioned

Requirements

  • Api 14+

Installation

Add JitPack to repositories in your project's root build.gradle file:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency to your module's build.gradle file:

dependencies {
    ...
    implementation 'com.github.mostafataghipour:androideasylist:1.1.1'
}

Usage

  1. Define your model
data class Movie(
    val id : String,
    val title : String
)

//optional: If you want to use DiffUtil capabilities (e.g. automatic animations like delete, insert, move , reload)
//          inherit 'Diffable' ptotocol
: Diffable {
    override val diffableIdentity: String
        get() = title!!

    //optional: this function need for automatic reload
    override fun isEqualTo(other: Any): Boolean {
        return if (other is Movie) return this == other else false
    }
}
  1. Define RecyclerViewAdapter
private val adapter: RecyclerViewAdapter<Movie> by lazy {

    val adapter = object : RecyclerViewAdapter<Movie>(this){
        override fun getLayout(viewType: Int): Int {
            return  R.layout.item_list
        }

        override fun bindView(item: Movie, position: Int, viewHolder: RecyclerView.ViewHolder) {
            viewHolder as GenericViewHolder
            
            val mMovieTitle: TextView? = viewHolder.getView<TextView>(R.id.movie_title)
            mMovieTitle?.text = item.title
        }
    }
        
    return adapter
}


override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_filtering)

    recyclerView.adapter = adapter
}
  1. Set Data
    adapter.items = yourItems
  1. That's it, for more samples please see example project

Thanks for

Author

Mostafa Taghipour, mostafa@taghipour.me

License

AndroidEasyList is available under the MIT license. See the LICENSE file for more info.