minor style change for better readability

This commit is contained in:
tibbi 2020-11-07 00:02:33 +01:00
parent ad5d1d2ebf
commit a6c1847701

View File

@ -53,7 +53,7 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
} }
fun handleOperation(operation: String) { fun handleOperation(operation: String) {
if (inputDisplayedFormula.isEmpty()) { if (inputDisplayedFormula == "") {
inputDisplayedFormula = "0" inputDisplayedFormula = "0"
} }
@ -112,7 +112,7 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
private fun getSecondValue(): Double { private fun getSecondValue(): Double {
val valueToCheck = inputDisplayedFormula.trimStart('-').replace(",", "") val valueToCheck = inputDisplayedFormula.trimStart('-').replace(",", "")
var value = valueToCheck.substring(valueToCheck.indexOfAny(operations) + 1) var value = valueToCheck.substring(valueToCheck.indexOfAny(operations) + 1)
if (value.isEmpty()) { if (value == "") {
value = "0" value = "0"
} }
@ -126,7 +126,7 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
if (lastKey != EQUALS) { if (lastKey != EQUALS) {
val valueToCheck = inputDisplayedFormula.trimStart('-').replace(",", "") val valueToCheck = inputDisplayedFormula.trimStart('-').replace(",", "")
val parts = valueToCheck.split(operationsRegex).filter { it.trim().isNotEmpty() } val parts = valueToCheck.split(operationsRegex).filter { it != "" }
baseValue = parts.first().replace(",", "").toDouble() baseValue = parts.first().replace(",", "").toDouble()
if (inputDisplayedFormula.startsWith("-")) { if (inputDisplayedFormula.startsWith("-")) {
baseValue *= -1 baseValue *= -1
@ -159,7 +159,7 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
fun handleClear() { fun handleClear() {
var newValue = inputDisplayedFormula.dropLast(1) var newValue = inputDisplayedFormula.dropLast(1)
if (newValue.isEmpty()) { if (newValue == "") {
newValue = "0" newValue = "0"
} }