From dd8a52451a29583de19adc01eae314aa7a337633 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Mon, 11 Feb 2019 20:10:21 -0600 Subject: [PATCH] Make sure to use the asset precision to correctly format the asset amount when reading QRs in SendTransactionActivity. --- .../fragments/SendTransactionFragment.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt index 5680722..c1f66f0 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt @@ -372,6 +372,8 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand tietTo.setText(invoice.to) + var balanceDetail: BalanceDetail? = null + // Try to select the invoice's Asset in the Assets spinner for (i in 0 until (mBalancesDetailsAdapter?.count ?: 0)) { if (mBalancesDetailsAdapter?.getItem(i)?.symbol == invoice.currency.toUpperCase() || @@ -379,6 +381,7 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand invoice.currency.replaceFirst("bit", "").toUpperCase() == mBalancesDetailsAdapter?.getItem(i)?.symbol)) { spAsset.setSelection(i) + balanceDetail = mBalancesDetailsAdapter?.getItem(i) break } } @@ -394,7 +397,7 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand amount += nextItem.quantity * nextItem.price } // TODO Improve pattern to account for different asset precisions - val df = DecimalFormat("####.########") + val df = DecimalFormat("####." + "#".repeat(balanceDetail?.precision ?: 5)) df.roundingMode = RoundingMode.CEILING df.decimalFormatSymbols = DecimalFormatSymbols(Locale.getDefault()) tietAmount.setText(df.format(amount))