In case,
When there is a list with 100 items and wanna change only some of them, should I need to create a new list for comparison with DiffUtil?
fun fetchDynamicItems() {
val items = repository.fetchOnlyDynamicItems()
replaceDynamicItems(items)
}
fun replaceDynamicItems(dynamicItems: List<DynamicItem>) {
val oldList = getCurrentList()
val newList = getCurrentList().map {
when (it) {
is DynamicItem -> dynamicItems.get(matchedIndex)
else -> it
}
}
// newList will be a copied list except DynamicItem
adapter.submitList(newList)
}
Is there a good way to use DiffUtil to change only a few items without creating a new List?