Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Vshnv authored Aug 26, 2023
1 parent bc4c9bb commit a643c71
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Adapt
Tired of writing Adapters for RecyclerViews? Adapt provides a simple to use DSLs to make writing adapters easier and faster!

## Example Usage

```kotlin
val adapter = adapt<String> {
defineViewTypes { data, position ->
if (data.toInt() % 5 == 0 || data.toInt() % 15 == 0) {
2
} else 1
}
create(1) {
ViewSource.BindingViewSource(LayoutTextItemBinding.inflate(layoutInflater), ViewBinding::getRoot)
}.bind { model, layoutTextItemBinding ->
layoutTextItemBinding.tvTest.text = model + " TYPE_1"
}
create(2) {
ViewSource.BindingViewSource(LayoutTextItemBinding.inflate(layoutInflater), ViewBinding::getRoot)
}.bind { model, layoutTextItemBinding ->
layoutTextItemBinding.tvTest.text = model + " TYPE_2"
}
}

recyclerView.adapter = adapter


adapter.submitData(listOf("Test A", "Test B", "Test C"))
```
For further info, checkout the demo app


0 comments on commit a643c71

Please sign in to comment.