A simple and minimal utility class to handle recyclerview lists
Installation • Usage • Contributing •
Installation (Kotlin DSL • Groovy )
- Install
jitpack
Locate your build.gradle.kts
file in the root project and add :
allprojects {
repositories {
google()
mavenCentral()
maven { setUrl("https://jitpack.io") } // add this line
}
}
For those with a higher gradle version, find settings.gradle.kts
in the root project folder and
add :
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { setUrl("https://jitpack.io") } // add this line
}
}
- Add the lazy adapter dependency
In your app module find build.gradle.kts
and add :
implementation("com.github.KotlinKenya:lazy-adapter:$version")
- Sync gradle and proceed use the library
- Install
jitpack
Locate your build.gradle
file in the root project and add :
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" } // add this line
}
}
For those with a higher gradle version, find settings.gradle
and add :
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // add this line
}
}
- Add Image Picker dependency
In your app module find build.gradle
and add :
implementation 'com.github.KotlinKenya:lazy-adapter:$version'
- let your data class extend the
LazyCompare()
data class Item (val name: String) : LazyCompare()
- create an xml file for your object
<!-- in this example our layout is item_layout.xml --> <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout ...> <androidx.cardview.widget.CardView ...> <TextView android:id="@+id/tv_text" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="16dp" android:text="TextView" /> </androidx.cardview.widget.CardView> </androidx.constraintlayout.widget.ConstraintLayout>
- create an adapter from the
LazyAdapter
classval adapter = LazyAdapter<Item, LayoutItemBinding>()
- initialize the view
adapter.onCreate { parent: ViewGroup -> val inflater = LayoutInflater.from(parent.context) LayoutItemBinding.inflate(inflater, parent, false) }
- bind the views
adapter.onBind {item : Item -> // you can access all views in here tvText.text = item.name }
- set the adapter to the recyclerview and submitList
recyclerview.adapter = adapter adapter.submitList(listOf<Item>()) // populate your list
Your contributions are especially welcome. Whether it comes in the form of code patches, ideas, discussion, bug reports, encouragement or criticism, your input is needed.
Visit issues to get started.