avoid modifying serversCache serverList from multithreading
Bug: app force close during updating subscribe Reroduce steps: quickly scroll up and down the RecyclerView during updating subscribe if the server list length is more than the screen height, the bug can be 100% reproduced Solution: reloadServerList from UI Thread Signed-off-by: zhaoguomanong <zhaoguomanong@gmail.com>
This commit is contained in:
@@ -54,13 +54,9 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
|
||||
fun reloadServerList() {
|
||||
serverList = MmkvManager.decodeServerList()
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
updateCache()
|
||||
launch(Dispatchers.Main) {
|
||||
updateListAction.value = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun removeServer(guid: String) {
|
||||
serverList.remove(guid)
|
||||
|
||||
Reference in New Issue
Block a user