Skip to content

Commit

Permalink
More IO improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed Jul 10, 2024
1 parent 2f7d73a commit 2a917f2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/src/main/kotlin/com/d4rk/cleaner/ui/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,15 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
* selectAllFiles(false) // Deselects all files
*/
fun selectAllFiles(selectAll: Boolean) {
scannedFiles.value?.forEach { file ->
fileSelectionStates[file] = selectAll
viewModelScope.launch {
withContext(Dispatchers.IO) {
scannedFiles.value?.forEach { file ->
fileSelectionStates[file] = selectAll
}
}
allFilesSelected.value = selectAll
_selectedFileCount.value = if (selectAll) fileSelectionStates.size else 0
}
allFilesSelected.value = selectAll
_selectedFileCount.value = fileSelectionStates.values.count { it }
}

/**
Expand Down Expand Up @@ -133,6 +137,7 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
}

withContext(Dispatchers.Main) {
fileSelectionStates.clear()
scannedFiles.value = filteredFiles
isAnalyzing.value = false
hasScanned.value = true
Expand Down

0 comments on commit 2a917f2

Please sign in to comment.