Improve: Optimize Reload method (AppDetailAdapter)

This commit is contained in:
LooKeR 2021-12-14 01:51:31 +05:30
parent b96c6a9e64
commit ebb77ffa71

View File

@ -888,7 +888,7 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
val from = items.indexOfFirst { it is Item.ReleaseItem } val from = items.indexOfFirst { it is Item.ReleaseItem }
val to = items.indexOfLast { it is Item.ReleaseItem } val to = items.indexOfLast { it is Item.ReleaseItem }
if (from in 0..to) { if (from in 0..to) {
notifyItemRangeChanged(0, 1) notifyItemRangeChanged(from, to - from)
} }
} else { } else {
notifyItemChanged(index, Payload.STATUS) notifyItemChanged(index, Payload.STATUS)
@ -972,7 +972,7 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
expanded += expandItem.expandType expanded += expandItem.expandType
if (expandItem.replace) { if (expandItem.replace) {
items[position - 1] = expandItem.items[0] items[position - 1] = expandItem.items[0]
notifyItemRangeChanged(position - 1, position) notifyItemRangeChanged(position - 1, 2)
} else { } else {
items.addAll(position, expandItem.items) items.addAll(position, expandItem.items)
if (position > 0) { if (position > 0) {
@ -984,7 +984,7 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
expanded -= expandItem.expandType expanded -= expandItem.expandType
if (expandItem.replace) { if (expandItem.replace) {
items[position - 1] = expandItem.items[1] items[position - 1] = expandItem.items[1]
notifyItemRangeChanged(position - 1, position) notifyItemRangeChanged(position - 1, 2)
} else { } else {
items.removeAt(position - 1) items.removeAt(position - 1)
if (position > 0) { if (position > 0) {