concurrent 异常处理+1

This commit is contained in:
renhaoting 2026-01-19 14:47:24 +08:00
parent e5c70e3d25
commit 1864a20dd2
1 changed files with 10 additions and 3 deletions

View File

@ -282,15 +282,22 @@ abstract class BaseRecordHelper<T: BaseRecord> {
mbgScope.launch {
try {
mRecordLocker.lock()
var replaceIndex = -1
var replaceItem : BaseRecord? = null
mRecordList.forEachIndexed { index, data ->
if (data.uuid == updateBean.uuid) {
mRecordList.remove(data)
mRecordList.add(index, updateBean)
replaceIndex = index
replaceItem = data
return@forEachIndexed
}
}
if (replaceIndex >= 0) {
mRecordList.remove(replaceItem)
mRecordList.add(replaceIndex, updateBean)
saveRecordList2Sp()
}
} finally {
mRecordLocker.unlock()
}