diff options
author | Torsten Grote <t@grobox.de> | 2023-01-03 10:00:21 -0300 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2023-01-03 10:00:59 -0300 |
commit | 43ad014f54c50fc2fa1cda3e1d6e24229637ad02 (patch) | |
tree | af345724bb0113acd718f5958c8e89c7f6d88dc6 /wallet | |
parent | 8643037f06c25be1508ef6027ef4d49e03beb620 (diff) | |
download | taler-android-43ad014f54c50fc2fa1cda3e1d6e24229637ad02.tar.gz taler-android-43ad014f54c50fc2fa1cda3e1d6e24229637ad02.tar.bz2 taler-android-43ad014f54c50fc2fa1cda3e1d6e24229637ad02.zip |
[wallet] Fix crash when exchange is missing currency
Can happen when exchange info in wallet-core was not yet fully loaded
#7480
Diffstat (limited to 'wallet')
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/exchanges/ExchangeAdapter.kt | 11 | ||||
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/withdraw/manual/ManualWithdrawFragment.kt | 5 |
2 files changed, 11 insertions, 5 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeAdapter.kt b/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeAdapter.kt index 5b0d947..e0cf5be 100644 --- a/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeAdapter.kt +++ b/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeAdapter.kt @@ -34,8 +34,9 @@ import net.taler.wallet.exchanges.ExchangeAdapter.ExchangeItemViewHolder @Serializable data class ExchangeItem( val exchangeBaseUrl: String, - val currency: String, - val paytoUris: List<String> + // can be null before exchange info in wallet-core was fully loaded + val currency: String? = null, + val paytoUris: List<String>, ) { val name: String get() = cleanExchange(exchangeBaseUrl) } @@ -79,7 +80,11 @@ internal class ExchangeAdapter( fun bind(item: ExchangeItem) { urlView.text = item.name - currencyView.text = context.getString(R.string.exchange_list_currency, item.currency) + currencyView.text = if (item.currency == null) { + context.getString(R.string.settings_version_unknown) + } else { + context.getString(R.string.exchange_list_currency, item.currency) + } if (selectOnly) { itemView.setOnClickListener { listener.onExchangeSelected(item) } overflowIcon.visibility = GONE diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/manual/ManualWithdrawFragment.kt b/wallet/src/main/java/net/taler/wallet/withdraw/manual/ManualWithdrawFragment.kt index 148b8c0..aae8c95 100644 --- a/wallet/src/main/java/net/taler/wallet/withdraw/manual/ManualWithdrawFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/withdraw/manual/ManualWithdrawFragment.kt @@ -67,7 +67,8 @@ class ManualWithdrawFragment : Fragment() { } private fun onCheckFees() { - if (ui.amountView.text?.isEmpty() != false) { + val currency = exchangeItem.currency + if (currency == null || ui.amountView.text?.isEmpty() != false) { ui.amountLayout.error = getString(R.string.withdraw_amount_error) return } @@ -79,7 +80,7 @@ class ManualWithdrawFragment : Fragment() { ui.amountLayout.error = getString(R.string.withdraw_amount_error) return } - val amount = Amount.fromDouble(exchangeItem.currency, value) + val amount = Amount.fromDouble(currency, value) ui.amountView.hideKeyboard() withdrawManager.getWithdrawalDetails(exchangeItem.exchangeBaseUrl, amount) |