Closed premacck closed 3 years ago
Hi. I am working on the viewBinding
delegate for ViewGroup
and RecyclerView.ViewHolder
and they will be part of the next release. The release will be on the next week. Your code is right. ViewGroup
doesn't have any connected LifecycleOwner
with it.
Hi @kirich1409 I was going through your example from ProfileView.kt to understand viewbinding in ViewGroups, and what I found curious was the need to use View.inflate(context, R.layout.view_profile, this)
with the view binding delegate.
Like when I just do private val binding = ViewProfileBinding.inflate(LayoutInflater.from(context), this)
I don't need to add View.inflate(...)
anymore
Is there any way to inflate the ViewBinding in the view group through the delegate property only? If not yet, can it be implemented?
The problem is that delegate is lazy and view will be attached on the first call of viewBinding delegate. I didn't add such kind of delegate because I wasn't sure about behavior.
Ah! I see what you mean, good catch, so even when using the delegate, we'll have to write binding
in the init { }
block anyways
I have an idea about that and will implement it
Thanks for this wonderful library @kirich1409 ! I'm really enjoying working with the non-reflection delegates
However, I was tinkering around for some ways to make the bindings in custom views delegated
Before:
My Delegate property:
After using delegate property:
I mean this approach is working, but I'm thinking is there any way of optimizing this approach?