|
|
|
|
@ -24,6 +24,8 @@ import retrofit2.Call |
|
|
|
|
import retrofit2.Response |
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Custom EditableDataFragment to manage the Bankroll data |
|
|
|
|
*/ |
|
|
|
|
@ -44,7 +46,7 @@ class BankrollDataFragment : EditableDataFragment(), StaticRowRepresentableDataS |
|
|
|
|
private var isRefreshingRate = false |
|
|
|
|
private var lastRefreshRateCall = 0L |
|
|
|
|
|
|
|
|
|
private val differentCurrency : Boolean |
|
|
|
|
private val shouldShowCurrencyRate : Boolean |
|
|
|
|
get() { |
|
|
|
|
return bankroll.currency?.let { bankrollCurrency -> |
|
|
|
|
bankrollCurrency.code != defaultCurrency.currencyCode |
|
|
|
|
@ -67,7 +69,7 @@ class BankrollDataFragment : EditableDataFragment(), StaticRowRepresentableDataS |
|
|
|
|
data?.let { |
|
|
|
|
val currencyCode = it.getStringExtra(CurrenciesFragment.INTENT_CURRENCY_CODE) |
|
|
|
|
onRowValueChanged(currencyCode, BankrollRow.CURRENCY) |
|
|
|
|
if (differentCurrency) { |
|
|
|
|
if (shouldShowCurrencyRate) { |
|
|
|
|
refreshRate() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -119,7 +121,7 @@ class BankrollDataFragment : EditableDataFragment(), StaticRowRepresentableDataS |
|
|
|
|
this.bankroll.currency?.rate?.let { rate -> |
|
|
|
|
row.editingDescriptors(mapOf("defaultValue" to CurrencyUtils.getCurrencyRateFormatter().format(rate))) |
|
|
|
|
} ?: run { |
|
|
|
|
row.editingDescriptors(mapOf("defaultValue" to "")) |
|
|
|
|
row.editingDescriptors(mapOf()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else -> null |
|
|
|
|
@ -169,7 +171,7 @@ class BankrollDataFragment : EditableDataFragment(), StaticRowRepresentableDataS |
|
|
|
|
rows.add(BankrollRow.LIVE) |
|
|
|
|
rows.add(CustomizableRowRepresentable(customViewType = RowViewType.HEADER_TITLE, resId = R.string.currency)) |
|
|
|
|
rows.add(BankrollRow.CURRENCY) |
|
|
|
|
if (this.differentCurrency) { |
|
|
|
|
if (this.shouldShowCurrencyRate) { |
|
|
|
|
rows.add(BankrollRow.RATE) |
|
|
|
|
rows.add(BankrollRow.REFRESH_RATE) |
|
|
|
|
} |
|
|
|
|
|