Skip to content

Instantly share code, notes, and snippets.

@NezSpencer
Created October 1, 2018 09:22
Show Gist options
  • Save NezSpencer/f1a0ea1ec69c5cd76f5eb16d94bbf8c2 to your computer and use it in GitHub Desktop.
Save NezSpencer/f1a0ea1ec69c5cd76f5eb16d94bbf8c2 to your computer and use it in GitHub Desktop.
method to get new cursor position for amount textWatcher
private fun getNewCursorPosition(digitCountToRightOfCursor : Int, numberString : String) : Int{
var position = 0
var c = digitCountToRightOfCursor
for (i in numberString.reversed()) {
if (c == 0)
break
if (i.isDigit())
c --
position ++
}
return numberString.length - position
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment