|
|
|
|
@ -21,23 +21,34 @@ import java.util.* |
|
|
|
|
|
|
|
|
|
class CurrenciesFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataSource, RowRepresentableDelegate { |
|
|
|
|
|
|
|
|
|
private val mostUsedCurrencyCodes = arrayListOf("EUR", "USD", "CAD", "GBP", "AUD", "CNY") |
|
|
|
|
private val systemCurrencies = Currency.getAvailableCurrencies() |
|
|
|
|
|
|
|
|
|
private val mostUsedCurrencies = this.mostUsedCurrencyCodes.map { code -> |
|
|
|
|
CurrencyRow( |
|
|
|
|
this.systemCurrencies.filter { |
|
|
|
|
it.currencyCode == code |
|
|
|
|
}.first() |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
companion object { |
|
|
|
|
val rowRepresentation : List<RowRepresentable> by lazy { |
|
|
|
|
val rows = ArrayList<RowRepresentable>() |
|
|
|
|
rows.addAll(mostUsedCurrencies) |
|
|
|
|
rows.add(SeparatorRowRepresentable()) |
|
|
|
|
rows.addAll(availableCurrencies) |
|
|
|
|
rows |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
val mostUsedCurrencyCodes = arrayListOf("EUR", "USD", "CAD", "GBP", "AUD", "CNY") |
|
|
|
|
val systemCurrencies = Currency.getAvailableCurrencies() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val availableCurrencies = this.systemCurrencies.filter { |
|
|
|
|
!mostUsedCurrencyCodes.contains(it.currencyCode) |
|
|
|
|
}.sortedBy { |
|
|
|
|
it.displayName |
|
|
|
|
}.map { |
|
|
|
|
CurrencyRow(it) |
|
|
|
|
private val mostUsedCurrencies = this.mostUsedCurrencyCodes.map { code -> |
|
|
|
|
CurrencyRow( |
|
|
|
|
this.systemCurrencies.filter { |
|
|
|
|
it.currencyCode == code |
|
|
|
|
}.first() |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private val availableCurrencies = this.systemCurrencies.filter { |
|
|
|
|
!mostUsedCurrencyCodes.contains(it.currencyCode) |
|
|
|
|
}.sortedBy { |
|
|
|
|
it.displayName |
|
|
|
|
}.map { |
|
|
|
|
CurrencyRow(it) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private class CurrencyRow(var currency:Currency) : RowRepresentable { |
|
|
|
|
@ -68,11 +79,7 @@ class CurrenciesFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataS |
|
|
|
|
// StaticRowRepresentableDataSource |
|
|
|
|
|
|
|
|
|
override fun adapterRows(): List<RowRepresentable>? { |
|
|
|
|
val rows = ArrayList<RowRepresentable>() |
|
|
|
|
rows.addAll(mostUsedCurrencies) |
|
|
|
|
rows.add(SeparatorRowRepresentable()) |
|
|
|
|
rows.addAll(availableCurrencies) |
|
|
|
|
return rows |
|
|
|
|
return CurrenciesFragment.rowRepresentation |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|