mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-06-05 21:49:13 +02:00
shortening more code
This commit is contained in:
@ -96,22 +96,19 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
|
|||||||
if (operations.contains(inputDisplayedFormula.last().toString())) {
|
if (operations.contains(inputDisplayedFormula.last().toString())) {
|
||||||
inputDisplayedFormula = inputDisplayedFormula.dropLast(1)
|
inputDisplayedFormula = inputDisplayedFormula.dropLast(1)
|
||||||
inputDisplayedFormula += getSign(operation)
|
inputDisplayedFormula += getSign(operation)
|
||||||
} else {
|
} else if (!inputDisplayedFormula.trimStart('-').contains(operationsRegex.toRegex())) {
|
||||||
if (!inputDisplayedFormula.trimStart('-').contains(operationsRegex.toRegex())) {
|
inputDisplayedFormula += getSign(operation)
|
||||||
inputDisplayedFormula += getSign(operation)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastKey == DIGIT && lastOperation != "" && operation == PERCENT) {
|
if (lastKey == DIGIT) {
|
||||||
val tempOperation = lastOperation
|
if (lastOperation != "" && operation == PERCENT) {
|
||||||
handlePercent()
|
handlePercent()
|
||||||
lastKey = tempOperation
|
} else {
|
||||||
lastOperation = tempOperation
|
secondValue = getSecondValue()
|
||||||
} else if (lastKey == DIGIT) {
|
calculateResult()
|
||||||
secondValue = getSecondValue()
|
if (!operations.contains(inputDisplayedFormula.last().toString())) {
|
||||||
calculateResult()
|
inputDisplayedFormula += getSign(operation)
|
||||||
if (!operations.contains(inputDisplayedFormula.last().toString())) {
|
}
|
||||||
inputDisplayedFormula += getSign(operation)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user