codestyle
This commit is contained in:
parent
817f41da3e
commit
b484c6dd48
|
|
@ -26,22 +26,21 @@ class AmountWithDecimalEditText @JvmOverloads constructor(
|
|||
private const val DEFAULT_DECIMAL_PART_LENGTH = 2
|
||||
private val hardcodedSymbols = listOf(GROUPING_SEPARATOR)
|
||||
private val possibleDecimalSeparators = listOf(",", ".")
|
||||
|
||||
}
|
||||
|
||||
private var textBefore = ""
|
||||
private var isTextWasArtificiallyChanged = true
|
||||
|
||||
var decimalSeparator = DEFAULT_DECIMAL_SEPARATOR
|
||||
set(value) {
|
||||
if (!possibleDecimalSeparators.contains(value))
|
||||
throw Exception("Not allowed decimal separator. Supports only: $possibleDecimalSeparators")
|
||||
field = value
|
||||
}
|
||||
|
||||
|
||||
var decimalPartLength = DEFAULT_DECIMAL_PART_LENGTH
|
||||
var isSeparatorCutInvalidDecimalLength = false
|
||||
|
||||
private var textBefore = ""
|
||||
private var isTextWasArtificiallyChanged = true
|
||||
|
||||
init {
|
||||
doOnTextChanged { text, _, _, _ ->
|
||||
if (isTextWasArtificiallyChanged) {
|
||||
|
|
@ -130,6 +129,8 @@ class AmountWithDecimalEditText @JvmOverloads constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun getTextWithoutFormatting() = text.toString().withoutFormatting()
|
||||
|
||||
private fun setTextWhichWasPasted(text: String) {
|
||||
var result = ""
|
||||
var decimalLength = -1
|
||||
|
|
@ -152,9 +153,6 @@ class AmountWithDecimalEditText @JvmOverloads constructor(
|
|||
setSelection(result.length)
|
||||
}
|
||||
|
||||
|
||||
fun getTextWithoutFormatting() = text.toString().withoutFormatting()
|
||||
|
||||
private fun String.withoutFormatting(): String {
|
||||
var result = this
|
||||
hardcodedSymbols.forEach { result = this.replace(it.toString(), "") }
|
||||
|
|
|
|||
Loading…
Reference in New Issue