diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/StringResourceCache.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/StringResourceCache.kt index 66330ef81..f42a58829 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/StringResourceCache.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/StringResourceCache.kt @@ -23,6 +23,7 @@ package com.vitorpamplona.amethyst.ui import android.content.Context import android.util.LruCache import androidx.annotation.DrawableRes +import androidx.annotation.PluralsRes import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.platform.LocalConfiguration @@ -131,6 +132,15 @@ fun stringRes( ) } +// Plural resolver for non-composable scope (e.g. onClick callbacks). Not cached: +// the resolved string varies by `count` quantity and the resourceCache is keyed by id. +fun pluralStringRes( + ctx: Context, + @PluralsRes id: Int, + count: Int, + vararg formatArgs: Any?, +): String = ctx.resources.getQuantityString(id, count, *formatArgs) + /** * This cache can only be used if the painter is the only copy on the screen * It should store a separate Painter for each size. It's safe to just assume