-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not an issue, just wanna ask about adapter #3
Comments
Nice to know the library was useful for you. 😄. Could you explain what you mean by custom functions in adapter? Im not sure I understand what you're reffering to. fun createPersonAdapter() = adapt<Person> {
fun generateAgeText(person: Person) {
return "Aged ${person.age}"
}
create {
val personBinding = LayoutPersonBinding.inflate(LayoutInflater.from(it.context), it, false)
ViewSource.BindingViewSource(personBinding, ViewBinding::getRoot)
}.bind {
binding.name.text = data.name
binding.age.text = generateAgeText(data)
}
} For filterable, I assume you mean filtering the submitted data. Currently no, the entire data passed to the adapter is used as the data set for the adapter. But this could definitely be something I could add on for the next version if you're interested. |
I would also be happy to make contribution. 😄 |
example:
|
done, built the things I wanted to include. Thanks, and wanna be friends? |
i have one more doubt. on row item binding click listener, do i have to directly call activity fun or var ref. eg.
which way is correct & better? |
Thats great! If you find anything you think would be useful in the library, always welcoming a PR 😄.
I usually define a function that creates the adapter using adapt and pass the callbacks to the function, that way I can reuse the adapter multiple times. fun createArticleAdapter(onArticleClicked: (index: Int, data: Article) -> Unit) = adapt<Article> {
create(...).bind {
binding.root.setOnClickListener {
onArticleClicked(index, data)
}
}
} This way I can recreate the adapter where required with its own custom callback. class MainActivity: AppCompatActivity {
private val articleAdaoter = createArticleAdapter(this::handleArticleClicked)
private fun handleArticleClicked(index: Int, data: Article) -> Unit {
// handle callback
}
} |
Nice. So, there is another doubt. Here is the code.
where i'm updating the data after long click. currently, it's not possible. |
Point 1 should be fine since Adapt implements Async diffing by default. Implementating contentEquals and itemEquals would be useful to help diffing: https://vshnv.github.io/adapt/dsl/ Having access to adapter inside bind and withLifecycle is definitely neccessary. I'll add For now what you can do is define a function outside the adapt scope thus capturing the |
hey @Vshnv, can we have a scheduled meet? Thanks & Regards |
Hey, |
I'm mostly available on Sunday or Saturday. 🫥 |
Hey, sorry for the delay. I got caught up in work. Added Saturdays and Sundays |
selected this coming Saturday 11am for meet time. |
Hey, Thanks you for the library, it's easy to use.
but, how can I add custom functions in adapter?
Can I also add Filterable?
If, YES then how can i add to it.
Thanks in advance.
The text was updated successfully, but these errors were encountered: