althaf
04/07/2022, 6:03 AMprivate fun getAmountLength(currency: CharSequence?, amount: CharSequence?): Int {
return when {
!currency.isNullOrEmpty() && !amount.isNullOrEmpty() -> currency.length + amount.length + 1
!amount.isNullOrEmpty() && currency.isNullOrEmpty() -> amount.length
amount.isNullOrEmpty() && !currency.isNullOrEmpty() -> currency.length
else -> 0
}
}
Adrijan Rogan
04/07/2022, 9:28 AMprivate fun getAmountLength(currency: CharSequence?, amount: CharSequence?): Int {
val currencyLength = currency?.length ?: 0
val amountLength = amount?.length ?: 0
// Add one if both curreny and amount are not empty
if (currencyLength > 0 && amountLength > 0)
return currencyLength + amountLength + 1
return currencyLength + amountLength
}
But why do you need this getAmountLength
?