Exit early

This commit is contained in:
Luna712 2024-07-08 23:46:55 -06:00 committed by GitHub
parent cd3940242f
commit 23842063b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -89,18 +89,19 @@ class DownloadViewModel : ViewModel() {
fun isAllSelected(): Boolean {
val currentSelected = selectedItems.value ?: return false
val headerItems = headerCards.value
val childItems = childCards.value
val isAllHeadersSelected = headerItems != null &&
if (headerItems != null &&
headerItems.count() == currentSelected.count() &&
headerItems.containsAll(currentSelected)
headerItems.containsAll(currentSelected)) return true
val isAllChildrenSelected = childItems != null &&
if (childItems != null &&
childItems.count() == currentSelected.count() &&
childItems.containsAll(currentSelected)
childItems.containsAll(currentSelected)) return true
return isAllHeadersSelected || isAllChildrenSelected
return false
}
fun updateList(context: Context) = viewModelScope.launchSafe {