Skip to content

Commit

Permalink
Handle commas in amounts properly
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapk00 committed Mar 27, 2019
1 parent 84ba841 commit d461aa9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/src/main/java/com/adityapk/zcash/zqwandroid/SendActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ class SendActivity : AppCompatActivity() {
setAmount(amt / (DataModel.mainResponseData?.zecprice ?: 0.0))
}

private fun setAmountZec(amt: Double) {
private fun setAmountZec(amt: Double?) {
if (amt == null) {
return;
}

// Since there is a text-change listner on the USD field, we set the USD first, then override the
// ZEC field manually.
val zprice = DataModel.mainResponseData?.zecprice ?: 0.0
Expand Down Expand Up @@ -252,10 +256,14 @@ class SendActivity : AppCompatActivity() {
if (data?.scheme == "zcash") {
sendAddress.setText(data.data?.host ?: "", TextView.BufferType.EDITABLE)

val amt = data.data?.getQueryParameter("amt") ?:
var amt = data.data?.getQueryParameter("amt") ?:
data.data?.getQueryParameter("amount")

// Remove all commas.
amt = amt?.replace(",", ".")

if (amt != null) {
setAmountZec(amt.toDouble())
setAmountZec(amt.toDoubleOrNull())
}

val memo = data.data?.getQueryParameter("memo")
Expand Down

0 comments on commit d461aa9

Please sign in to comment.