Loading packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/util/Collections.kt +21 −0 Original line number Diff line number Diff line Loading @@ -19,7 +19,23 @@ package com.android.settingslib.spa.framework.util import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch /** * Performs the given [action] on each element asynchronously. */ suspend inline fun <T> Iterable<T>.asyncForEach(crossinline action: (T) -> Unit) { coroutineScope { forEach { launch { action(it) } } } } /** * Returns a list containing the results of asynchronously applying the given [transform] function * to each element in the original collection. */ suspend inline fun <R, T> Iterable<T>.asyncMap(crossinline transform: (T) -> R): List<R> = coroutineScope { map { item -> Loading @@ -27,6 +43,11 @@ suspend inline fun <R, T> Iterable<T>.asyncMap(crossinline transform: (T) -> R): }.awaitAll() } /** * Returns a list containing only elements matching the given [predicate]. * * The filter operation is done asynchronously. */ suspend inline fun <T> Iterable<T>.asyncFilter(crossinline predicate: (T) -> Boolean): List<T> = asyncMap { item -> item to predicate(item) } .filter { it.second } Loading packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/preference/TwoTargetPreference.kt +1 −1 Original line number Diff line number Diff line Loading @@ -67,6 +67,6 @@ private fun PreferenceDivider() { Modifier .padding(horizontal = SettingsDimension.itemPaddingEnd) .size(width = 1.dp, height = SettingsDimension.itemDividerHeight) .background(color = MaterialTheme.colorScheme.onSurface.copy(SettingsOpacity.Disabled)) .background(color = MaterialTheme.colorScheme.onSurface.copy(SettingsOpacity.Divider)) ) } Loading
packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/util/Collections.kt +21 −0 Original line number Diff line number Diff line Loading @@ -19,7 +19,23 @@ package com.android.settingslib.spa.framework.util import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch /** * Performs the given [action] on each element asynchronously. */ suspend inline fun <T> Iterable<T>.asyncForEach(crossinline action: (T) -> Unit) { coroutineScope { forEach { launch { action(it) } } } } /** * Returns a list containing the results of asynchronously applying the given [transform] function * to each element in the original collection. */ suspend inline fun <R, T> Iterable<T>.asyncMap(crossinline transform: (T) -> R): List<R> = coroutineScope { map { item -> Loading @@ -27,6 +43,11 @@ suspend inline fun <R, T> Iterable<T>.asyncMap(crossinline transform: (T) -> R): }.awaitAll() } /** * Returns a list containing only elements matching the given [predicate]. * * The filter operation is done asynchronously. */ suspend inline fun <T> Iterable<T>.asyncFilter(crossinline predicate: (T) -> Boolean): List<T> = asyncMap { item -> item to predicate(item) } .filter { it.second } Loading
packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/preference/TwoTargetPreference.kt +1 −1 Original line number Diff line number Diff line Loading @@ -67,6 +67,6 @@ private fun PreferenceDivider() { Modifier .padding(horizontal = SettingsDimension.itemPaddingEnd) .size(width = 1.dp, height = SettingsDimension.itemDividerHeight) .background(color = MaterialTheme.colorScheme.onSurface.copy(SettingsOpacity.Disabled)) .background(color = MaterialTheme.colorScheme.onSurface.copy(SettingsOpacity.Divider)) ) }