Fixed
Status Update
Comments
yb...@google.com <yb...@google.com> #3
Have a pending CL that fixes the issue. We were not considering the include as a View when it is a binding class.
yb...@google.com <yb...@google.com> #4
fix merged. now we'll allow all View attributes in include tags. note that it does not resolve the type of the view so it will always be considered as View, not the root tag of the included layout (for the purposes of the binding adapters and view attribute setters)
Description
```
@BindingAdapter("android:visibility", "invisibilityMode", requireAll = false)
fun bindVisibility(view: View, visibility: Boolean?, invisibleMode: Int?) {
visibility ?: return
if (invisibleMode != null && invisibleMode != View.INVISIBLE && invisibleMode != View.GONE) {
throw IllegalArgumentException("Invisibility mode must be one of View.INVISIBILE or View.GONE")
}
view.visibility = if (visibility) View.VISIBLE else invisibleMode ?: View.INVISIBLE
}
```
I can use it for example for a TextView like this: `android:visibility="@{someLiveData instanceof SomeEnumValueInLiveData}"`
But when I do the same thing for an <include> layout, I get an error `incompatible types: boolean cannot be converted to int`. The generated code:
```
com.example.ViewBindingsKt.bindVisibility(this.mboundView2, someLiveDataInstanceofSomeEnumValueInLiveData, (java.lang.Integer)null); // for text view
this.viewEmpty.getRoot().setVisibility(someLiveDataInstanceofSomeEnumValueInLiveData); // for include, error
```
This happens with AGP 3.4.1