Skip to content

Commit

Permalink
Update dependency androidx.collection:collection-ktx to v1.3.0 (#3140)
Browse files Browse the repository at this point in the history
* Update dependency androidx.collection:collection-ktx to v1.3.0

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Daniel Frett <[email protected]>
  • Loading branch information
renovate[bot] and frett authored Oct 11, 2023
1 parent e565297 commit ce7579e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ androidx-appcompat = "androidx.appcompat:appcompat:1.6.1"
androidx-arch-core-testing = "androidx.arch.core:core-testing:2.2.0"
androidx-browser = "androidx.browser:browser:1.6.0"
androidx-cardview = "androidx.cardview:cardview:1.0.0"
androidx-collection-ktx = "androidx.collection:collection-ktx:1.2.0"
androidx-collection-ktx = "androidx.collection:collection-ktx:1.3.0"
androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "androidx-compose-material" }
androidx-compose-material-icons-extended = { module = "androidx.compose.material:material-icons-extended", version.ref = "androidx-compose-material" }
androidx-compose-material3 = "androidx.compose.material3:material3:1.1.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ class MultiLanguageToolActivityDataModel @Inject constructor(
@VisibleForTesting
internal val translations =
locales.asLiveData().switchFold(ImmutableLiveData(emptyList<Pair<Locale, Translation?>>())) { acc, locale ->
distinctToolCode.switchMap { translationCache.get(it, locale).withInitialValue(null) }
distinctToolCode.switchMap { translationCache[it, locale]!!.withInitialValue(null) }
.distinctUntilChanged()
.combineWith(acc.distinctUntilChanged()) { it, translations -> translations + Pair(locale, it) }
}.map { it.toMap() }

@VisibleForTesting
internal val manifests =
locales.asLiveData().switchFold(ImmutableLiveData(emptyList<Pair<Locale, Manifest?>>())) { acc, locale ->
distinctToolCode.switchMap { manifestCache.get(it, locale).asLiveData().withInitialValue(null) }
distinctToolCode.switchMap { manifestCache[it, locale]!!.asLiveData().withInitialValue(null) }
.distinctUntilChanged()
.combineWith(acc.distinctUntilChanged()) { it, manifests -> manifests + Pair(locale, it) }
}.map { it.toMap() }
Expand Down Expand Up @@ -147,8 +147,8 @@ class MultiLanguageToolActivityDataModel @Inject constructor(

val activeLoadingState = distinctToolCode.switchCombineWith(activeLocale) { tool, l ->
combine(
manifestCache.get(tool, l).asLiveData(),
translationCache.get(tool, l),
manifestCache[tool, l]!!.asLiveData(),
translationCache[tool, l]!!,
supportedType.asLiveData(),
isConnected,
isInitialSyncFinished.asLiveData()
Expand Down Expand Up @@ -224,4 +224,5 @@ class MultiLanguageToolActivityDataModel @Inject constructor(
}
}

private fun <T> LruCache<TranslationKey, T>.get(tool: String?, locale: Locale?) = get(TranslationKey(tool, locale))!!
private operator fun <T : Any> LruCache<TranslationKey, T>.get(tool: String?, locale: Locale?) =
get(TranslationKey(tool, locale))

0 comments on commit ce7579e

Please sign in to comment.