Fix spacing

This commit is contained in:
Luna712 2024-07-10 15:19:27 -06:00 committed by GitHub
parent a26aeb6534
commit e01d9b8456
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -207,7 +207,10 @@ class DownloadViewModel : ViewModel() {
} }
} }
fun updateChildList(context: Context, folder: String) = viewModelScope.launchSafe { fun updateChildList(
context: Context,
folder: String
) = viewModelScope.launchSafe {
val data = withContext(Dispatchers.IO) { context.getKeys(folder) } val data = withContext(Dispatchers.IO) { context.getKeys(folder) }
val visual = withContext(Dispatchers.IO) { val visual = withContext(Dispatchers.IO) {
data.mapNotNull { key -> data.mapNotNull { key ->
@ -245,62 +248,64 @@ class DownloadViewModel : ViewModel() {
} }
} }
fun handleMultiDelete(context: Context, onDeleteConfirm: () -> Unit) = fun handleMultiDelete(
viewModelScope.launchSafe { context: Context,
val selectedItemsList = selectedItems.value ?: emptyList() onDeleteConfirm: () -> Unit
) = viewModelScope.launchSafe {
val selectedItemsList = selectedItems.value ?: emptyList()
val ids = mutableListOf<Int>() val ids = mutableListOf<Int>()
val seriesNames = mutableListOf<String>() val seriesNames = mutableListOf<String>()
val names = mutableListOf<String>() val names = mutableListOf<String>()
var parentName: String? = null var parentName: String? = null
selectedItemsList.forEach { item -> selectedItemsList.forEach { item ->
when (item) { when (item) {
is VisualDownloadCached.Header -> { is VisualDownloadCached.Header -> {
if (item.data.type.isEpisodeBased()) { if (item.data.type.isEpisodeBased()) {
val episodes = context.getKeys(DOWNLOAD_EPISODE_CACHE) val episodes = context.getKeys(DOWNLOAD_EPISODE_CACHE)
.mapNotNull { .mapNotNull {
context.getKey<VideoDownloadHelper.DownloadEpisodeCached>( context.getKey<VideoDownloadHelper.DownloadEpisodeCached>(
it it
) )
} }
.filter { it.parentId == item.data.id } .filter { it.parentId == item.data.id }
.map { it.id } .map { it.id }
ids.addAll(episodes) ids.addAll(episodes)
val episodeInfo = "${item.data.name} (${item.totalDownloads} ${ val episodeInfo = "${item.data.name} (${item.totalDownloads} ${
context.resources.getQuantityString( context.resources.getQuantityString(
R.plurals.episodes, R.plurals.episodes,
item.totalDownloads item.totalDownloads
).lowercase() ).lowercase()
})" })"
seriesNames.add(episodeInfo) seriesNames.add(episodeInfo)
} else { } else {
ids.add(item.data.id)
names.add(item.data.name)
}
}
is VisualDownloadCached.Child -> {
ids.add(item.data.id) ids.add(item.data.id)
val parent = context.getKey<VideoDownloadHelper.DownloadHeaderCached>( names.add(item.data.name)
DOWNLOAD_HEADER_CACHE,
item.data.parentId.toString()
)
parentName = parent?.name
names.add(
context.getNameFull(
item.data.name,
item.data.episode,
item.data.season
)
)
} }
} }
}
val data = DeleteConfirmationData(parentName, seriesNames.toList(), names.toList()) is VisualDownloadCached.Child -> {
showDeleteConfirmationDialog(context, ids, data, onDeleteConfirm) ids.add(item.data.id)
val parent = context.getKey<VideoDownloadHelper.DownloadHeaderCached>(
DOWNLOAD_HEADER_CACHE,
item.data.parentId.toString()
)
parentName = parent?.name
names.add(
context.getNameFull(
item.data.name,
item.data.episode,
item.data.season
)
)
}
}
}
val data = DeleteConfirmationData(parentName, seriesNames.toList(), names.toList())
showDeleteConfirmationDialog(context, ids, data, onDeleteConfirm)
} }
private fun showDeleteConfirmationDialog( private fun showDeleteConfirmationDialog(