|
|
|
|
@ -45,27 +45,46 @@ class CurrenciesFragment : BaseFragment(), StaticRowRepresentableDataSource, Row |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private val availableCurrencies = this.systemCurrencies.filter { |
|
|
|
|
!mostUsedCurrencyCodes.contains(it.currencyCode) |
|
|
|
|
}.filter { |
|
|
|
|
UserDefaults.availableCurrencyLocales.filter { currencyLocale -> |
|
|
|
|
Currency.getInstance(currencyLocale).currencyCode == it.currencyCode |
|
|
|
|
}.isNotEmpty() |
|
|
|
|
}.sortedBy { |
|
|
|
|
it.displayName |
|
|
|
|
}.map { |
|
|
|
|
CurrencyRow(it) |
|
|
|
|
} |
|
|
|
|
private val availableCurrencies = |
|
|
|
|
Locale.getAvailableLocales() |
|
|
|
|
.mapNotNull { |
|
|
|
|
try { |
|
|
|
|
Currency.getInstance(it) |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
null |
|
|
|
|
} |
|
|
|
|
}.toSet() |
|
|
|
|
.filter { !mostUsedCurrencyCodes.contains(it.currencyCode) } |
|
|
|
|
.filter { |
|
|
|
|
UserDefaults.availableCurrencyLocales.any { currencyLocale -> |
|
|
|
|
Currency.getInstance(currencyLocale).currencyCode == it.currencyCode |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.sortedBy { it.displayName } |
|
|
|
|
.map { CurrencyRow(it) } |
|
|
|
|
|
|
|
|
|
// private val availableCurrencies = this.systemCurrencies.filter { |
|
|
|
|
// !mostUsedCurrencyCodes.contains(it.currencyCode) |
|
|
|
|
// }.filter { |
|
|
|
|
// UserDefaults.availableCurrencyLocales.filter { currencyLocale -> |
|
|
|
|
// Currency.getInstance(currencyLocale).currencyCode == it.currencyCode |
|
|
|
|
// }.isNotEmpty() |
|
|
|
|
// }.sortedBy { |
|
|
|
|
// it.displayName |
|
|
|
|
// }.map { |
|
|
|
|
// CurrencyRow(it) |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private class CurrencyRow(var currency: Currency) : RowRepresentable { |
|
|
|
|
|
|
|
|
|
override fun getDisplayName(context: Context): String { |
|
|
|
|
return currency.getDisplayName(Locale.getDefault()).capitalize() |
|
|
|
|
return this.currency.getDisplayName(Locale.getDefault()).capitalize() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var currencyCode: String = currency.currencyCode |
|
|
|
|
var currencySymbol: String = currency.getSymbol(Locale.getDefault()) |
|
|
|
|
var currencyCode: String = this.currency.currencyCode |
|
|
|
|
var currencySymbol: String = this.currency.getSymbol(Locale.getDefault()) |
|
|
|
|
var currencyCodeAndSymbol: String = "${this.currencyCode} (${this.currencySymbol})" |
|
|
|
|
|
|
|
|
|
override val viewType: Int = RowViewType.TITLE_VALUE.ordinal |
|
|
|
|
@ -110,9 +129,6 @@ class CurrenciesFragment : BaseFragment(), StaticRowRepresentableDataSource, Row |
|
|
|
|
|
|
|
|
|
// RowRepresentableDelegate |
|
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, tag: Int) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val intent = Intent() |
|
|
|
|
intent.putExtra(INTENT_CURRENCY_CODE, (row as CurrencyRow).currency.currencyCode) |
|
|
|
|
this.activity?.setResult(Activity.RESULT_OK, intent) |
|
|
|
|
|