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 { mbgScope.launch {
try { try {
mRecordLocker.lock() mRecordLocker.lock()
var replaceIndex = -1
var replaceItem : BaseRecord? = null
mRecordList.forEachIndexed { index, data -> mRecordList.forEachIndexed { index, data ->
if (data.uuid == updateBean.uuid) { if (data.uuid == updateBean.uuid) {
mRecordList.remove(data) replaceIndex = index
mRecordList.add(index, updateBean) replaceItem = data
return@forEachIndexed return@forEachIndexed
} }
} }
saveRecordList2Sp() if (replaceIndex >= 0) {
mRecordList.remove(replaceItem)
mRecordList.add(replaceIndex, updateBean)
saveRecordList2Sp()
}
} finally { } finally {
mRecordLocker.unlock() mRecordLocker.unlock()
} }