You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
Release 4.3.2 added the @nullable annotation for the items property in the AbsDelegationAdapter class. In this regard, all the adapters in our project has been broken. All of them were built according to the following pattern:
This approach has been used in several different projects that I have worked on.
After the update, this approach stopped working, since now we are operating on a nullable items list:
I have not found an example in Readme how to use ListDelegationAdapter + DiffUtil when list is nullable.
It is possible to check for null each time or write requireNotNull(items) / items!!, but in this case a lot of adapters has to be rewritten.
Is there any correct way to work with ListDelegationAdapter + DiffUtil?
The text was updated successfully, but these errors were encountered:
Hello,
I feel your pain but the items list can defacto be null (so this was a flaw in previous versions of this library). We could discuss if it makes sense (and technically be possible) to make it late init instead of nullable.
But in your concrete example, isn't it enough to just dont run DiffUtils if oldItems is null.
funsetData(list:List<TestItem>) {
val oldData = items
items = list
dispatchUpdates(oldData)
}
privatefundispatchUpdates(oldData:List<TestItem>?) { //OldData is nullableif (oldData ==null)
this.notidyDatasetChanged()
elseDiffutil
.calculateDiff(TestDiffCallback(items, oldData), false)
.dispatchUpdatesTo(this)
}
Hi!
Release 4.3.2 added the @nullable annotation for the
items
property in the AbsDelegationAdapter class. In this regard, all the adapters in our project has been broken. All of them were built according to the following pattern:This approach has been used in several different projects that I have worked on.
After the update, this approach stopped working, since now we are operating on a nullable items list:
I have not found an example in Readme how to use ListDelegationAdapter + DiffUtil when list is nullable.
It is possible to check for null each time or write
requireNotNull(items)
/items!!
, but in this case a lot of adapters has to be rewritten.Is there any correct way to work with ListDelegationAdapter + DiffUtil?
The text was updated successfully, but these errors were encountered: