-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nullable items
property in AbsDelegationAdapter after 4.3.2.
#110
Comments
Hello, But in your concrete example, isn't it enough to just dont run DiffUtils if fun setData(list: List<TestItem>) {
val oldData = items
items = list
dispatchUpdates(oldData)
}
private fun dispatchUpdates(oldData: List<TestItem>?) { //OldData is nullable
if (oldData ==null)
this.notidyDatasetChanged()
else
Diffutil
.calculateDiff(TestDiffCallback(items, oldData), false)
.dispatchUpdatesTo(this)
} |
Thank you for your answer! I think it would be nice if you made items lateinit or somehow non null. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: