Skip to content
This repository was archived by the owner on Jul 11, 2025. It is now read-only.

Merge pull request #215 from android/update-agp-4-2-1#233

Open
StylianosGakis wants to merge 1 commit intoandroid:mainfrom
StylianosGakis:fix/flowers-adapter-diffutil-implementation
Open

Merge pull request #215 from android/update-agp-4-2-1#233
StylianosGakis wants to merge 1 commit intoandroid:mainfrom
StylianosGakis:fix/flowers-adapter-diffutil-implementation

Conversation

@StylianosGakis
Copy link

Fix DiffUtil.ItemCallback implementation

The areItemsTheSame documentation explicitly says:
"For example, if your items have unique ids, this method should check their id equality."

In the current state, the DiffUtil.ItemCallback is implemented wrong.

override fun areItemsTheSame(oldItem: Flower, newItem: Flower): Boolean {
return oldItem == newItem
}
override fun areContentsTheSame(oldItem: Flower, newItem: Flower): Boolean {
return oldItem.id == newItem.id
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant