fixed names in AmountWithDecimalDecorator.kt

This commit is contained in:
stanislav 2020-09-10 16:25:23 +03:00
parent 5b39a9ba1f
commit e2a3599ea6
1 changed files with 11 additions and 11 deletions

View File

@ -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