android ConcurrentModificationException 错误

错误代码

 val subList = newList.subList(position, endPosition + 1)
            val mergeList: MutableList<IChatTab> = mutableListOf()    //展开文件里面的tab,放到一个folder里面
            val tabIterator: Iterator<IChatTab> = subList.iterator()
            while (tabIterator.hasNext()) {
                val tab = tabIterator.next()
                if (!(tab.type == ChatTabViewType.FOLDER_START || tab.type == ChatTabViewType.FOLDER_END)) {
                    mergeList.add(tab)
                }
            }
            newList.removeAll(subList.toSet())
            if (mergeList.isNotEmpty()) {
                val folderTab = ChatFolderTab()
                folderTab.folderId = mergeList[0].folderId
                folderTab.roomList.addAll(mergeList)
                newList.add(position, folderTab)
                chatRoomTabAdapter.data = newList
                chatRoomTabAdapter.notifyDataSetChanged()
                ChatRoomConfig.removeFolderOpenedId(mergeList[0].folderId)
            }

posted @ 2024-06-16 22:30  hangox  阅读(6)  评论(0编辑  收藏  举报