Currency converter: Fix crash when system uses unsupported locale
Close #950
This commit is contained in:
parent
a4be78d6b1
commit
6718767d6b
@ -15,8 +15,16 @@ class CurrencyRepository(
|
||||
private val context: Context,
|
||||
) {
|
||||
|
||||
private fun getOwnCurrency(): String {
|
||||
return try {
|
||||
java.util.Currency.getInstance(Locale.getDefault()).currencyCode ?: "USD"
|
||||
} catch (e: IllegalArgumentException) {
|
||||
"USD"
|
||||
}
|
||||
}
|
||||
|
||||
private val currencySymbolAliases = buildMap {
|
||||
val ownCurrency = java.util.Currency.getInstance(Locale.getDefault()).currencyCode ?: "USD"
|
||||
val ownCurrency = getOwnCurrency()
|
||||
|
||||
put("€", "EUR")
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user