Force amount validation in SendTransactionFragment when an asset is selected in Assets spinner. The amount validation was done only after the user changed the amount but it has to also be validated when the user selects a different Asset, because it is probable to have less of that asset than what is already typed in the amount field.
This commit is contained in:
parent
bda2299cb5
commit
6dc5e54ad1
1 changed files with 6 additions and 3 deletions
|
@ -191,9 +191,8 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
|
||||||
tietAmount.textChanges()
|
tietAmount.textChanges()
|
||||||
.skipInitialValue()
|
.skipInitialValue()
|
||||||
.debounce(500, TimeUnit.MILLISECONDS)
|
.debounce(500, TimeUnit.MILLISECONDS)
|
||||||
.map { it.toString().trim() }
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe { validateAmount(it!!) }
|
.subscribe { validateAmount() }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,6 +209,8 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
|
||||||
|
|
||||||
tvAvailableAssetAmount.text =
|
tvAvailableAssetAmount.text =
|
||||||
String.format("%." + Math.min(balance.precision, 8) + "f %s", amount, balance.symbol)
|
String.format("%." + Math.min(balance.precision, 8) + "f %s", amount, balance.symbol)
|
||||||
|
|
||||||
|
validateAmount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +382,9 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun validateAmount(txtAmount: String) {
|
private fun validateAmount() {
|
||||||
|
val txtAmount = tietAmount.text.toString()
|
||||||
|
|
||||||
if (mBalancesDetailsAdapter?.isEmpty != false) return
|
if (mBalancesDetailsAdapter?.isEmpty != false) return
|
||||||
val balance = mBalancesDetailsAdapter?.getItem(spAsset.selectedItemPosition) ?: return
|
val balance = mBalancesDetailsAdapter?.getItem(spAsset.selectedItemPosition) ?: return
|
||||||
val currentAmount = balance.amount.toDouble() / Math.pow(10.0, balance.precision.toDouble())
|
val currentAmount = balance.amount.toDouble() / Math.pow(10.0, balance.precision.toDouble())
|
||||||
|
|
Loading…
Reference in a new issue