androidbroadcast / ViewBindingPropertyDelegate

Make work with Android View Binding simpler
https://proandroiddev.com/make-android-view-binding-great-with-kotlin-b71dd9c87719
Apache License 2.0
1.42k stars 102 forks source link

Lazy initialization of viewBinding #70

Closed dpproduction closed 3 years ago

dpproduction commented 3 years ago

Is there any way to init viewBinding with lazy statement ? Have tried by this way private val viewBinding by lazy { viewBinding( FragmentGraphContentBinding::bind ) } But in this case viewBinding has type ViewBindingProperty<ChannelsGraphFragment, FragmentGraphContentBinding> And I don't understand how to use it for getting views.

kirich1409 commented 3 years ago

Why do you need that? viewBinding has lazy like behaviour by default

dpproduction commented 3 years ago

Hm, I need it because of using AsyncLayoutInflater. onCreateView of fragment returns only empty container, then main view has async inflated and added to this container.

kirich1409 commented 3 years ago

You can use base delegate and ovveride how to create view from for ViewBinding. Look for the overload