Created
October 1, 2018 09:22
-
-
Save NezSpencer/f1a0ea1ec69c5cd76f5eb16d94bbf8c2 to your computer and use it in GitHub Desktop.
method to get new cursor position for amount textWatcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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