concurrent 异常处理+1
This commit is contained in:
parent
e5c70e3d25
commit
1864a20dd2
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (replaceIndex >= 0) {
|
||||||
|
mRecordList.remove(replaceItem)
|
||||||
|
mRecordList.add(replaceIndex, updateBean)
|
||||||
saveRecordList2Sp()
|
saveRecordList2Sp()
|
||||||
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
mRecordLocker.unlock()
|
mRecordLocker.unlock()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue