adding a list empty check

This commit is contained in:
tibbi 2021-03-27 20:49:38 +01:00
parent 2b8fe04820
commit def1240f0f

View file

@ -168,6 +168,10 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
if (lastKey != EQUALS) {
val valueToCheck = inputDisplayedFormula.trimStart('-').replace(",", "")
val parts = valueToCheck.split(operationsRegex).filter { it != "" }
if (parts.isEmpty()) {
return
}
baseValue = Formatter.stringToDouble(parts.first())
if (inputDisplayedFormula.startsWith("-")) {
baseValue *= -1