Skip to content

Instantly share code, notes, and snippets.

@Oleur
Created December 20, 2021 15:43
Show Gist options
  • Save Oleur/86f3558843cccdff84d5ddac5e4280f5 to your computer and use it in GitHub Desktop.
Save Oleur/86f3558843cccdff84d5ddac5e4280f5 to your computer and use it in GitHub Desktop.
Phone number formatting
s.forEachIndexed { index, char ->
if (PhoneNumberUtils.isNonSeparator(char)) {
if (lastNonSeparator.code != 0) {
formatted = getFormattedNumber(lastNonSeparator, hasCursor)
hasCursor = false
}
lastNonSeparator = char
}
if (index == curIndex) {
hasCursor = true
}
}
if (lastNonSeparator.code != 0) {
formatted = getFormattedNumber(lastNonSeparator, hasCursor)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment