diff --git a/src/main/kotlin/ca/gosyer/data/translation/XmlResourceBundle.kt b/src/main/kotlin/ca/gosyer/data/translation/XmlResourceBundle.kt index c6215ded..308bb792 100644 --- a/src/main/kotlin/ca/gosyer/data/translation/XmlResourceBundle.kt +++ b/src/main/kotlin/ca/gosyer/data/translation/XmlResourceBundle.kt @@ -52,17 +52,17 @@ class XmlResourceBundle internal constructor(internal val lookup: ConcurrentHash private fun String.replaceAndroid() = replace("\\n", "%n") fun getStringA(key: String): String { - return Formatter().format(getString(key).replaceAndroid()) - .let { formatter -> - formatter.toString().also { formatter.close() } - } + return Formatter().use { + it.format(getString(key).replaceAndroid()) + .toString() + } } fun getString(key: String, vararg replacements: Any?): String { - return Formatter().format(getString(key).replaceAndroid(), *replacements) - .let { formatter -> - formatter.toString().also { formatter.close() } - } + return Formatter().use { + it.format(getString(key).replaceAndroid(), *replacements) + .toString() + } } companion object { diff --git a/src/main/kotlin/ca/gosyer/ui/sources/settings/model/SourceSettingsView.kt b/src/main/kotlin/ca/gosyer/ui/sources/settings/model/SourceSettingsView.kt index 5f447e03..9cf5997d 100644 --- a/src/main/kotlin/ca/gosyer/ui/sources/settings/model/SourceSettingsView.kt +++ b/src/main/kotlin/ca/gosyer/ui/sources/settings/model/SourceSettingsView.kt @@ -127,12 +127,10 @@ sealed class SourceSettingsView { } } -fun withFormat(text: String, value: Any?): String { - return Formatter().format(text, value) - .let { formatter -> - formatter.toString() - .also { formatter.close() } - } +private fun withFormat(text: String, value: Any?): String { + return Formatter().use { + it.format(text, value).toString() + } } fun SourceSettingsView(index: Int, preference: SourcePreference): SourceSettingsView<*, *> {