code reformat

This commit is contained in:
dagkalis 2021-08-29 18:28:47 +03:00
parent a7cb74eb70
commit 97b9e4ab2c
2 changed files with 7 additions and 6 deletions

View File

@ -43,7 +43,7 @@ class MainActivity : SimpleActivity(), Calculator {
btn_root.setOnClickListener { calc.handleOperation(ROOT); checkHaptic(it) }
btn_minus.setOnLongClickListener {
calc.turnToNegative();
calc.turnToNegative()
}
btn_clear.setOnClickListener { calc.handleClear(); checkHaptic(it) }

View File

@ -126,15 +126,16 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
fun turnToNegative(): Boolean {
// turn to negative only if there is a baseValue alone ( not 0 )
if (!inputDisplayedFormula.trimStart('-').any { it.toString() in operations } && inputDisplayedFormula.replace(",", "").toDouble() != 0.0) {
if (inputDisplayedFormula.first() == '-') {
inputDisplayedFormula = inputDisplayedFormula.substring(1)
} else {
inputDisplayedFormula = "-$inputDisplayedFormula"
}
showNewResult(inputDisplayedFormula)
return true
}
return false
}