reduce method size

This commit is contained in:
Vladimir 2020-08-27 14:43:17 +05:00
parent b83bf97a67
commit b66cd421a8
1 changed files with 2 additions and 4 deletions

View File

@ -44,16 +44,14 @@ class AmountWithDecimalDecorator(
fun getTextWithoutFormatting(decimalSeparatorToReplace: String = decimalSeparator): String =
textBefore.withoutFormatting(decimalSeparatorToReplace)
@Suppress("detekt.TooGenericExceptionCaught", "detekt.LongMethod")
@Suppress("detekt.TooGenericExceptionCaught")
private fun doOnTextChanged(text: String) {
if (isTextWasArtificiallyChanged) {
isTextWasArtificiallyChanged = false
val cursorPosition = editText.selectionStart
try {
var currentText = text
possibleDecimalSeparators.forEach {
currentText = currentText.replace(it, decimalSeparator)
}
possibleDecimalSeparators.forEach { currentText = currentText.replace(it, decimalSeparator) }
if (isTextFormatIncorrect(currentText)) {
setTextWhenNewInputIncorrect(currentText, cursorPosition)