From e2a3599ea6b8702f1d0c2f5ed426e1581580fe8f Mon Sep 17 00:00:00 2001 From: stanislav Date: Thu, 10 Sep 2020 16:25:23 +0300 Subject: [PATCH] fixed names in AmountWithDecimalDecorator.kt --- .../widget/AmountWithDecimalDecorator.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/views/src/main/java/ru/touchin/roboswag/views/widget/AmountWithDecimalDecorator.kt b/views/src/main/java/ru/touchin/roboswag/views/widget/AmountWithDecimalDecorator.kt index e7e34ec..0e3794f 100644 --- a/views/src/main/java/ru/touchin/roboswag/views/widget/AmountWithDecimalDecorator.kt +++ b/views/src/main/java/ru/touchin/roboswag/views/widget/AmountWithDecimalDecorator.kt @@ -54,10 +54,10 @@ class AmountWithDecimalDecorator( try { var currentText = text possibleDecimalSeparators.forEach { currentText = currentText.replace(it, decimalSeparator) } - val currentIntegerPathLength = currentText.withoutFormatting().split(decimalSeparator)[0].length + val currentIntegerPartLength = currentText.withoutFormatting().split(decimalSeparator)[0].length - if (isIntegerPathToLong(currentIntegerPathLength)) { - currentText = trimIntegerPath(currentText) + if (isIntegerPartToLong(currentIntegerPartLength)) { + currentText = trimIntegerPart(currentText) } if (isTextFormatIncorrect(currentText)) { @@ -71,7 +71,7 @@ class AmountWithDecimalDecorator( } val currentDecimalPartLength = currentText.split(decimalSeparator).getOrNull(1)?.length - if (isDecimalPathTooLong(currentDecimalPartLength)) { + if (isDecimalPartTooLong(currentDecimalPartLength)) { setTextWhenNewInputIncorrect(currentText, cursorPosition) return } @@ -96,13 +96,13 @@ class AmountWithDecimalDecorator( } } - private fun isIntegerPathToLong(currentIntegerPathLength: Int) = currentIntegerPathLength > integerPartLength + private fun isIntegerPartToLong(currentIntegerPartLength: Int) = currentIntegerPartLength > integerPartLength - private fun trimIntegerPath(currentText: String): String { - val textSplit = currentText.withoutFormatting().split(decimalSeparator) - val integerPath = textSplit[0] - val decimalPath = if (textSplit.size > 1) decimalSeparator + textSplit[1] else "" - return integerPath.take(integerPartLength) + decimalPath + private fun trimIntegerPart(currentText: String): String { + val splittedText = currentText.withoutFormatting().split(decimalSeparator) + val integerPart = splittedText[0] + val decimalPart = if (splittedText.size > 1) decimalSeparator + splittedText[1] else "" + return integerPart.take(integerPartLength) + decimalPart } private fun isTextFormatIncorrect(currentText: String) = @@ -155,7 +155,7 @@ class AmountWithDecimalDecorator( } } - private fun isDecimalPathTooLong(currentDecimalPartLength: Int?) = + private fun isDecimalPartTooLong(currentDecimalPartLength: Int?) = !isSeparatorCutInvalidDecimalLength && currentDecimalPartLength != null && currentDecimalPartLength > decimalPartLength