Hi there!
I liked your library and appreciate that, but I have a problem :
I saw you put setContentView() function inside getValue() method of delegation function; So if we don't want to access any property of binding variable like binding.root, etc, then setContentView() never calls and we don't see anything in the view when we launch app.
So my question is: Why didn't you call setContentView in init block like this? Did you do this for a reason?
Cause in this case it's not necessary to use any of binding properties to make sure setContentView function calls.
init {
@Suppress("UNCHECKED_CAST")
lifecycle.addObserver(object : DefaultLifecycleObserver {
override fun onCreate(owner: LifecycleOwner) {
/**
* inflate View class
*/
val inflateMethod = bindingClass.getMethod("inflate", LayoutInflater::class.java)
/**
* Bind layout
*/
val invokeLayout = inflateMethod.invoke(null, activity.layoutInflater) as T
/**
* Set the content view
*/
activity.setContentView(invokeLayout.root)
binding = invokeLayout
}
})
}
Thanks in advance.
Hi there!
I liked your library and appreciate that, but I have a problem :
I saw you put setContentView() function inside getValue() method of delegation function; So if we don't want to access any property of binding variable like binding.root, etc, then setContentView() never calls and we don't see anything in the view when we launch app.
So my question is: Why didn't you call setContentView in init block like this? Did you do this for a reason?
Cause in this case it's not necessary to use any of binding properties to make sure setContentView function calls.
Thanks in advance.