Created
July 23, 2019 10:02
-
-
Save Nublo/2862fac2815ccc3f72f8eef791644de5 to your computer and use it in GitHub Desktop.
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
class DigitsTrimStartFilter(private val max: Int) : InputFilter { | |
override fun filter(...): CharSequence? { | |
val s = source.subSequence(start, end).filter { it.isDigit() } | |
val keep = max - (dest.length - (dend - dstart)) | |
return when { | |
keep <= 0 -> "" | |
keep >= s.length -> null // keep original | |
else -> s.subSequence(s.length - keep, s.length) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment