Closed goemic closed 1 year ago
Did you fix the problem?I had the same problem
Hi, sorry for the late response! The problem is that we need to explicitly define the type when providing the OnItemBindClass via databinding.
This was the source of the problem in my layout file:
<data>
<variable
name="listItemBinding"
type="me.tatarka.bindingcollectionadapter2.itembindings.OnItemBindClass" />
</data>
You can solve the problem by explicitly defining the type of OnItemBindClass<> :
<data>
<variable
name="listItemBinding"
type="me.tatarka.bindingcollectionadapter2.itembindings.OnItemBindClass<com.my.sampleclass>" />
</data>
Since this does not look nice and feels bad for my, I decided to declare my OnItemBindClass variable in my ViewModel which I provide anyways via databinding to the data section in my layout files. Thereby I can simply reference
<androidx.recyclerview.widget.RecyclerView
app:itemBinding="@{viewModel.onItemBindClass}"
..
/>
Issue
We can't upgrade our gradle version. binding-collection-adapter has been working fine in our projects with the following gradle versions:
build.gradle (project)
classpath 'com.android.tools.build:gradle:3.4.3'
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
We use version 3.2.0 of bindingcollectionadapter, but this problem occurs as well when we upgrade to 4.0.0.
As soon as I try to update the gradle versions (e.g. 3.4.3 -> 4.0.1 but happens as well with the 3.5.2) I get the following error:
error: method setAdapter in class BindingRecyclerViewAdapters cannot be applied to given types; me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapters.setAdapter(this.mboundView3, me.tatarka.bindingcollectionadapter2.BindingCollectionAdapters.toItemBinding(listItemBinding), viewModelSupportedItemList, (me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter)null, (me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter.ItemIds)null, (me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter.ViewHolderFactory)null, (androidx.recyclerview.widget.AsyncDifferConfig)null); ^ required: RecyclerView,ItemBinding<? super T#1>,List<T#1>,BindingRecyclerViewAdapter<T#1>,ItemIds<? super T#1>,ViewHolderFactory,AsyncDifferConfig<T#1> found: RecyclerView,ItemBinding<CAP#1>,ObservableList<FileItem>,BindingRecyclerViewAdapter,ItemIds,ViewHolderFactory,AsyncDifferConfig reason: inference variable T#1 has incompatible bounds equality constraints: FileItem upper bounds: T#2,CAP#2,Object where T#1,T#2 are type-variables: T#1 extends Object declared in method <T#1>setAdapter(RecyclerView,ItemBinding<? super T#1>,List<T#1>,BindingRecyclerViewAdapter<T#1>,ItemIds<? super T#1>,ViewHolderFactory,AsyncDifferConfig<T#1>) T#2 extends Object declared in method <T#2>toItemBinding(OnItemBind<T#2>) where CAP#1,CAP#2 are fresh type-variables: CAP#1 extends Object from capture of ? CAP#2 extends Object from capture of ?