3
3
Fork 1
mirror of https://github.com/recloudstream/cloudstream.git synced 2024-08-15 01:53:11 +00:00

Update separator and remove unnecessary methods

This commit is contained in:
Luna712 2024-07-07 10:00:10 -06:00 committed by GitHub
parent 3dc61d69e1
commit fc2e2ec0f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -71,14 +71,6 @@ class DownloadViewModel : ViewModel() {
_selectedIds.postValue(HashMap())
}
private fun getSelectedIds(): List<Int> {
return selectedIds.value?.keys?.toList() ?: emptyList()
}
private fun getSelectedNames(): List<String> {
return selectedIds.value?.values?.toList() ?: emptyList()
}
fun updateList(context: Context) = viewModelScope.launchSafe {
val children = withContext(Dispatchers.IO) {
context.getKeys(DOWNLOAD_EPISODE_CACHE)
@ -167,14 +159,14 @@ class DownloadViewModel : ViewModel() {
}
fun handleMultiDelete(context: Context) = viewModelScope.launchSafe {
val ids: List<Int> = getSelectedIds()
val names: List<String> = getSelectedNames()
val ids: List<Int> = selectedIds.value?.keys?.toList() ?: emptyList()
val names: List<String> = selectedIds.value?.values?.toList() ?: emptyList()
showDeleteConfirmationDialog(context, ids, names)
}
private fun showDeleteConfirmationDialog(context: Context, ids: List<Int>, names: List<String>) {
val formattedNames = names.joinToString(separator = "\n") { "- $it" }
val formattedNames = names.joinToString(separator = "\n") { " $it" }
val message = context.getString(R.string.delete_message_multiple).format(formattedNames)
val builder: AlertDialog.Builder = AlertDialog.Builder(context)