simplifying addDigit

This commit is contained in:
tibbi 2020-11-06 23:56:00 +01:00
parent 15e6f060e3
commit ad5d1d2ebf

View file

@ -3,7 +3,6 @@ package com.simplemobiletools.calculator.helpers
import android.content.Context
import com.simplemobiletools.calculator.R
import com.simplemobiletools.calculator.operation.PercentOperation
import com.simplemobiletools.commons.extensions.areDigitsOnly
import com.simplemobiletools.commons.extensions.toast
import net.objecthunter.exp4j.ExpressionBuilder
@ -23,15 +22,10 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
}
private fun addDigit(number: Int) {
if (inputDisplayedFormula == "0" && number.toString().areDigitsOnly()) {
if (inputDisplayedFormula == "0") {
inputDisplayedFormula = ""
}
val value = getSecondValue().toString()
if (value == "0" && number.toString().areDigitsOnly()) {
inputDisplayedFormula = inputDisplayedFormula.dropLast(1)
}
inputDisplayedFormula += number
showNewResult(inputDisplayedFormula)
}