|
|
@ -74,45 +74,39 @@ abstract class DiffRecyclerAdapter<ITEM, VB : ViewBinding>(protected val context |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
suspend fun updateItem(item: ITEM) { |
|
|
|
fun updateItem(item: ITEM) { |
|
|
|
withContext(Dispatchers.Main) { |
|
|
|
synchronized(asyncListDiffer) { |
|
|
|
synchronized(asyncListDiffer) { |
|
|
|
kotlin.runCatching { |
|
|
|
kotlin.runCatching { |
|
|
|
val index = asyncListDiffer.currentList.indexOf(item) |
|
|
|
val index = asyncListDiffer.currentList.indexOf(item) |
|
|
|
if (index >= 0) { |
|
|
|
if (index >= 0) { |
|
|
|
asyncListDiffer.currentList[index] = item |
|
|
|
asyncListDiffer.currentList[index] = item |
|
|
|
notifyItemChanged(index) |
|
|
|
notifyItemChanged(index) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
suspend fun updateItem(position: Int, payload: Any) { |
|
|
|
fun updateItem(position: Int, payload: Any) { |
|
|
|
withContext(Dispatchers.Main) { |
|
|
|
synchronized(asyncListDiffer) { |
|
|
|
synchronized(asyncListDiffer) { |
|
|
|
kotlin.runCatching { |
|
|
|
kotlin.runCatching { |
|
|
|
val size = itemCount |
|
|
|
val size = itemCount |
|
|
|
if (position in 0 until size) { |
|
|
|
if (position in 0 until size) { |
|
|
|
notifyItemChanged(position, payload) |
|
|
|
notifyItemChanged(position, payload) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
suspend fun updateItems(fromPosition: Int, toPosition: Int, payloads: Any) { |
|
|
|
fun updateItems(fromPosition: Int, toPosition: Int, payloads: Any) { |
|
|
|
withContext(Dispatchers.Main) { |
|
|
|
synchronized(asyncListDiffer) { |
|
|
|
synchronized(asyncListDiffer) { |
|
|
|
kotlin.runCatching { |
|
|
|
kotlin.runCatching { |
|
|
|
val size = itemCount |
|
|
|
val size = itemCount |
|
|
|
if (fromPosition in 0 until size && toPosition in 0 until size) { |
|
|
|
if (fromPosition in 0 until size && toPosition in 0 until size) { |
|
|
|
notifyItemRangeChanged( |
|
|
|
notifyItemRangeChanged( |
|
|
|
fromPosition, |
|
|
|
fromPosition, |
|
|
|
toPosition - fromPosition + 1, |
|
|
|
toPosition - fromPosition + 1, |
|
|
|
payloads |
|
|
|
payloads |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|