|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package net.pokeranalytics.android.ui.fragment |
|
|
|
|
|
|
|
|
|
import android.app.Activity |
|
|
|
|
import android.content.Intent |
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
import android.view.View |
|
|
|
|
@ -16,12 +17,14 @@ import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SeparatorRowRepresentable |
|
|
|
|
import net.pokeranalytics.android.util.Preferences |
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
class CurrenciesFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataSource, RowRepresentableDelegate { |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
const val INTENT_CURRENCY_CODE = "INTENT_CURRENCY_CODE" |
|
|
|
|
|
|
|
|
|
val rowRepresentation : List<RowRepresentable> by lazy { |
|
|
|
|
val rows = ArrayList<RowRepresentable>() |
|
|
|
|
rows.addAll(mostUsedCurrencies) |
|
|
|
|
@ -30,9 +33,8 @@ class CurrenciesFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataS |
|
|
|
|
rows |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
val mostUsedCurrencyCodes = arrayListOf("EUR", "USD", "CAD", "GBP", "AUD", "CNY") |
|
|
|
|
val systemCurrencies = Currency.getAvailableCurrencies() |
|
|
|
|
|
|
|
|
|
private val mostUsedCurrencyCodes = arrayListOf("EUR", "USD", "CAD", "GBP", "AUD", "CNY") |
|
|
|
|
private val systemCurrencies = Currency.getAvailableCurrencies() |
|
|
|
|
|
|
|
|
|
private val mostUsedCurrencies = this.mostUsedCurrencyCodes.map { code -> |
|
|
|
|
CurrencyRow( |
|
|
|
|
@ -89,8 +91,9 @@ class CurrenciesFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataS |
|
|
|
|
|
|
|
|
|
// RowRepresentableDelegate |
|
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
|
|
|
Preferences.setCurrencyCode((row as CurrencyRow).currency.currencyCode, this.context!!) |
|
|
|
|
this.activity?.setResult(Activity.RESULT_OK) |
|
|
|
|
val intent = Intent() |
|
|
|
|
intent.putExtra(INTENT_CURRENCY_CODE, (row as CurrencyRow).currency.currencyCode) |
|
|
|
|
this.activity?.setResult(Activity.RESULT_OK, intent) |
|
|
|
|
this.activity?.finish() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|