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
- Api 14+
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'
}
- 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
}
}
- 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
}
- Set Data
adapter.items = yourItems
- That's it, for more samples please see example project
Mostafa Taghipour, [email protected]
AndroidEasyList is available under the MIT license. See the LICENSE file for more info.