Skip to content

Instantly share code, notes, and snippets.

@meshileya
Last active July 27, 2022 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meshileya/b7858a1d96c819f98e02606a1c81d586 to your computer and use it in GitHub Desktop.
Save meshileya/b7858a1d96c819f98e02606a1c81d586 to your computer and use it in GitHub Desktop.
fun fixAppend(displayStr: StringBuilder, digit: String, txtView: TextView): Boolean {
if (displayStr.length <= 11) {
displayStr.append(digit)
var newAmount = displayStr.toString().toDouble()
// fix new input
newAmount *= 10.00
if ("00" == digit) newAmount *= 10.00
val updatedAmount = DecimalFormat("0.00").format(newAmount)
txtView.text = updatedAmount.toString()
// binding.txtAmount.text = updatedAmount.toString()
}
return true
}
fun fixDelete(displayStr: StringBuilder, textView: TextView) {
var bd = BigDecimal(displayStr.toString())
bd = bd.movePointLeft(1)
textView.text = bd.toString()
// binding.txtAmount.text = bd.toString()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment