Last active
December 20, 2021 16:41
-
-
Save Oleur/4c6c4d7fe31b0e754efc8720d3267dd2 to your computer and use it in GitHub Desktop.
Compose offsets for PhoneNumber VisualTransformation
This file contains 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
val originalToTransformed = mutableListOf<Int>() | |
val transformedToOriginal = mutableListOf<Int>() | |
var specialCharsCount = 0 | |
formatted?.forEachIndexed { index, char -> | |
if (!PhoneNumberUtils.isNonSeparator(char)) { | |
specialCharsCount++ | |
} else { | |
originalToTransformed.add(index) | |
} | |
transformedToOriginal.add(index - specialCharsCount) | |
} | |
originalToTransformed.add(originalToTransformed.maxOrNull()?.plus(1) ?: 0) | |
transformedToOriginal.add(transformedToOriginal.maxOrNull()?.plus(1) ?: 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment