From 97b9e4ab2c47d6ad3d809dbb470703b0a597d69a Mon Sep 17 00:00:00 2001 From: dagkalis Date: Sun, 29 Aug 2021 18:28:47 +0300 Subject: [PATCH] code reformat --- .../calculator/activities/MainActivity.kt | 2 +- .../calculator/helpers/CalculatorImpl.kt | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt index 3dde21c4..c363d6e4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt @@ -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) } diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt index aa972a59..fe0f4952 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt @@ -123,18 +123,19 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) { showNewResult(inputDisplayedFormula) } - fun turnToNegative() : Boolean{ + 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() == '-') { + if (!inputDisplayedFormula.trimStart('-').any { it.toString() in operations } && inputDisplayedFormula.replace(",", "").toDouble() != 0.0) { + if (inputDisplayedFormula.first() == '-') { inputDisplayedFormula = inputDisplayedFormula.substring(1) - }else{ + } else { inputDisplayedFormula = "-$inputDisplayedFormula" } + showNewResult(inputDisplayedFormula) return true } + return false }