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

Pass LayoutInflater #21

Closed DatL4g closed 3 years ago

DatL4g commented 3 years ago

I would like to pass a LayoutInflater. Normally I did it like this:

private lateinit var binding: FragmentExampleBinding

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
    // doing some changes to inflater here
    binding = FragmentExampleBinding.inflate(inflater, container, false)
    return binding.root
}

Is it possible to extend the current delegation by passing these parameter?

kirich1409 commented 3 years ago

It's possible to do that, but in that case, the property delegate will have no sense because you will init it lazy. Only valuable functionality will be the handling of the lifecycle to prevent memory leaks

kirich1409 commented 3 years ago

It's will be easy to add ViewBinding.inflate(LayoutInflater) support