Created
March 16, 2023 12:24
-
-
Save ananth10/bb4f2d8e7a95f4fd2bf0b11ea0b307b8 to your computer and use it in GitHub Desktop.
How To Use DiffUtil In RecyclerView Adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val diffUtil = object : DiffUtil.ItemCallback<String>() { | |
override fun areItemsTheSame(oldItem: String, newItem: String): Boolean { | |
return oldItem == newItem | |
} | |
override fun areContentsTheSame(oldItem: String, newItem: String): Boolean { | |
return oldItem == newItem | |
} | |
} | |
private val recyclerListDiff = AsyncListDiffer(this, diffUtil) | |
var imageList: List<String> | |
get() = recyclerListDiff.currentList | |
set(value) = recyclerListDiff.submitList(value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment