mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-03-17 11:50:03 +01:00
Merge pull request #241 from Aga-C/fix-clear-zero
Fixed inserting zero after using clear
This commit is contained in:
commit
9b9fb93f48
@ -288,9 +288,26 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
|
||||
}
|
||||
|
||||
fun handleClear() {
|
||||
val lastDeletedValue = inputDisplayedFormula.last().toString()
|
||||
var newValue = inputDisplayedFormula.dropLast(1)
|
||||
if (newValue == "") {
|
||||
newValue = "0"
|
||||
} else {
|
||||
if (operations.contains(lastDeletedValue) || lastKey == EQUALS) {
|
||||
lastOperation = ""
|
||||
}
|
||||
val lastValue = newValue.last().toString()
|
||||
lastKey = when {
|
||||
operations.contains(lastValue) -> {
|
||||
CLEAR
|
||||
}
|
||||
lastValue == "." -> {
|
||||
DECIMAL
|
||||
}
|
||||
else -> {
|
||||
DIGIT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newValue = newValue.trimEnd(',')
|
||||
|
Loading…
x
Reference in New Issue
Block a user