mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-02-02 08:56:51 +01:00
minor style change for better readability
This commit is contained in:
parent
ad5d1d2ebf
commit
a6c1847701
@ -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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user