Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mradkhambek/leoadapter
https://github.com/mradkhambek/leoadapter
Last synced: 12 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mradkhambek/leoadapter
- Owner: MrAdkhambek
- License: mit
- Created: 2020-01-23T14:09:31.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-07-22T14:10:02.000Z (over 1 year ago)
- Last Synced: 2023-07-22T15:22:51.237Z (over 1 year ago)
- Language: Kotlin
- Size: 846 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LeoAdapter
[![Maven Central](https://img.shields.io/maven-central/v/com.adkhambek.leo/leo.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%com.adkhambek.leo)```gradle
allprojects {
repositories {
...
mavenCentral()
}
}
``````grad
dependencies {
implementation 'com.adkhambek.leo:leo:$lastVersion'
}
``````kotlin
val leoAdapter: LeoAdapter = binding.recycler.setupAdapter(
ItemBinding::inflate
) { itemBinding, index, item ->
itemBinding.textView.text = "${item.name} $index"
itemBinding.textView.setBackgroundResource(colors[index % colors.size])itemBinding.root.setOnClickListener {
TODO("logic here")
}
}val data = (1..1000).map {
Person(it, it, "Adam")
}leoAdapter.setList(data)
``````kotlin
val leoAdapter: LeoAdapter = binding.viewPager2.setupAdapter(
ItemBinding::inflate
) { itemBinding, index, item ->
itemBinding.textView.text = "${item.name} $index"
itemBinding.textView.setBackgroundResource(colors[index % colors.size])itemBinding.root.setOnClickListener {
TODO("logic here")
}
}val data = (1..1000).map {
Person(it, it, "Adam")
}leoAdapter.setList(data)
```## Paging Adapter
```kotlin
val leoAdapter: LeoPagingAdapter = binding.recycler.setupPagingAdapter(
viewBinding = RecyclerItemBinding::inflate,
diffCallback = DIFF_UTIL,
) { itemBinding, index, item -> // item is nullable 😢
itemBinding.textView.text = "${item?.name} $index"
itemBinding.textView.setBackgroundResource(colors[index % colors.size])itemBinding.root.setOnClickListener {
TODO("logic here")
}
}val data : PaginData = TODO()
leoAdapter.submitData(data)
```