[2.14.0]fix删除Bag包列表偶现ConcurrentModificationException问题

This commit is contained in:
xuxinchao
2023-02-23 15:43:00 +08:00
parent d48e4c8f57
commit 63a34b00d3

View File

@@ -28,6 +28,7 @@ import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseConfig.bagMan
import com.zhjt.mogo_core_function_devatools.badcase.record.Audition
import kotlinx.android.synthetic.main.layout_badcase_manager.view.*
import java.util.*
import kotlin.collections.ArrayList
/**
@@ -61,6 +62,8 @@ class BadCaseManagerView @JvmOverloads constructor(
private var isNameModify = false
private val deleteDataList: ArrayList<BagInfoEntity> = ArrayList()
init {
LayoutInflater.from(context).inflate(R.layout.layout_badcase_manager, this, true)
initView()
@@ -381,14 +384,23 @@ class BadCaseManagerView @JvmOverloads constructor(
0 -> {
ToastUtils.showShort("${bagManager.uploadCosResp.key} 上传cos桶成功")
}
1 -> {
//执行中
}
2 -> {
ToastUtils.showShort("${bagManager.uploadCosResp.key} 上传cos桶copy过程失败,原因:${bagManager.uploadCosResp.message}")
ToastUtils.showShort("${bagManager.uploadCosResp.key} 上传cos桶执行python失败")
}
3 -> {
ToastUtils.showShort("${bagManager.uploadCosResp.key} 上传cos桶合并过程失败,原因:${bagManager.uploadCosResp.message}")
ToastUtils.showShort("${bagManager.uploadCosResp.key} 上传cos桶拷贝过程失败")
}
4 -> {
ToastUtils.showShort("${bagManager.uploadCosResp.key} 上传cos桶上传过程失败,原因:${bagManager.uploadCosResp.message}")
ToastUtils.showShort("${bagManager.uploadCosResp.key} 上传cos桶合并过程失败")
}
5 -> {
ToastUtils.showShort("${bagManager.uploadCosResp.key} 上传cos桶上传过程失败")
}
else -> {
ToastUtils.showShort("${bagManager.uploadCosResp.key} 上传cos桶 ${bagManager.uploadCosResp.message}")
}
}
@@ -404,39 +416,55 @@ class BadCaseManagerView @JvmOverloads constructor(
bagManagerList.remove(deleteBagInfo)
//更新列表
// bagManagerListAdapter?.setData(bagManagerEntity.bagsInfoResp)
if(bagManagerList.size>0){
//继续执行删除命令
bagManagerEntity.reqType = 4
bagManagerEntity.keyReq = bagManagerList[0].key
CallerAutoPilotManager.sendBagManagerCmd(bagManagerEntity)
}
}
}
//遍历列表如当天Bag全部删除同时把日期标题也删除更新列表
deleteDataList.clear()
val titleIterator = bagManagerEntity.bagsInfoResp.iterator()
while(titleIterator.hasNext()){
val titleBagInfo = titleIterator.next()
if(titleBagInfo.itemType == 1){
val bagIterator = bagManagerEntity.bagsInfoResp.iterator()
var hasBag = false
var bagBagInfo: BagInfoEntity ?= null
while(bagIterator.hasNext()){
val bagBagInfo = bagIterator.next()
bagBagInfo = bagIterator.next()
if(bagBagInfo.itemType == 0){
bagBagInfo.timestamp?.let {
if(it.contains(titleBagInfo.timestamp.toString())){
bagBagInfo.timestamp.let {
if(it.contains(titleBagInfo.timestamp)){
hasBag = true
}
}
}
}
if(!hasBag){
bagIterator.remove()
// bagIterator.remove()
titleBagInfo.let { deleteDataList.add(it) }
}
}
}
if(deleteDataList.isNotEmpty()){
val deleteIterator = bagManagerEntity.bagsInfoResp.iterator()
while(deleteIterator.hasNext()){
val deleteInfo = deleteIterator.next()
if(deleteDataList.contains(deleteInfo)){
deleteIterator.remove()
}
}
}
if(bagManagerList.size == 0){
tvCancelSelect.performClick()
}
if(bagManagerList.size>0){
//继续执行删除命令
bagManagerEntity.reqType = 4
bagManagerEntity.keyReq = bagManagerList[0].key
CallerAutoPilotManager.sendBagManagerCmd(bagManagerEntity)
}
//更新列表
bagManagerListAdapter?.setData(bagManagerEntity.bagsInfoResp)
}