Skip to content

Commit

Permalink
Added the cleaning functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed Jul 9, 2024
1 parent c4d1b98 commit bdd1a3f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/src/main/kotlin/com/d4rk/cleaner/ui/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,22 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
return
}

// TODO: Implement your cleaning logic here
viewModelScope.launch(Dispatchers.IO) {
val filesToDelete = fileSelectionStates.filter { it.value }.keys
filesToDelete.forEach { file ->
if (file.exists()) {
file.deleteRecursively()
}
}

withContext(Dispatchers.Main) {
scannedFiles.value = scannedFiles.value?.filterNot { filesToDelete.contains(it) }
fileSelectionStates.clear()
selectAllFiles(false)
_selectedFileCount.value = 0
updateStorageInfo()
}
}
}

/**
Expand Down

0 comments on commit bdd1a3f

Please sign in to comment.