mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-03-12 01:10:08 +01:00
autoformatting the code, no real change
This commit is contained in:
parent
34ee9e5b04
commit
cffa735c2a
@ -98,8 +98,8 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||||||
private fun getDisplayedNumberAsDouble() = Formatter.stringToBigDecimal(displayedNumber!!)
|
private fun getDisplayedNumberAsDouble() = Formatter.stringToBigDecimal(displayedNumber!!)
|
||||||
|
|
||||||
fun handleResult() {
|
fun handleResult() {
|
||||||
if(moreOperationsInRaw){
|
if (moreOperationsInRaw) {
|
||||||
val index = displayedNumber!!.indexOfAny(operations,0,false)
|
val index = displayedNumber!!.indexOfAny(operations, 0, false)
|
||||||
displayedNumber = displayedNumber!!.substring(index + 1)
|
displayedNumber = displayedNumber!!.substring(index + 1)
|
||||||
}
|
}
|
||||||
moreOperationsInRaw = false
|
moreOperationsInRaw = false
|
||||||
@ -136,14 +136,14 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun handleOperation(operation: String) {
|
fun handleOperation(operation: String) {
|
||||||
if(operation != ROOT) {
|
if (operation != ROOT) {
|
||||||
if (inputDisplayedFormula!!.last() == '+' || inputDisplayedFormula!!.last() == '-' || inputDisplayedFormula!!.last() == '*' || inputDisplayedFormula!!.last() == '/' || inputDisplayedFormula!!.last() == '^' || inputDisplayedFormula!!.last() == '%') {
|
if (inputDisplayedFormula!!.last() == '+' || inputDisplayedFormula!!.last() == '-' || inputDisplayedFormula!!.last() == '*' || inputDisplayedFormula!!.last() == '/' || inputDisplayedFormula!!.last() == '^' || inputDisplayedFormula!!.last() == '%') {
|
||||||
inputDisplayedFormula = inputDisplayedFormula!!.dropLast(1)
|
inputDisplayedFormula = inputDisplayedFormula!!.dropLast(1)
|
||||||
inputDisplayedFormula += getSign(operation)
|
inputDisplayedFormula += getSign(operation)
|
||||||
} else {
|
} else {
|
||||||
if(!inputDisplayedFormula!!.contains('+') && !inputDisplayedFormula!!.contains('-') && !inputDisplayedFormula!!.contains('*') && !inputDisplayedFormula!!.contains('/') && !inputDisplayedFormula!!.contains('^') && !inputDisplayedFormula!!.contains('%')) {
|
if (!inputDisplayedFormula!!.contains('+') && !inputDisplayedFormula!!.contains('-') && !inputDisplayedFormula!!.contains('*') && !inputDisplayedFormula!!.contains('/') && !inputDisplayedFormula!!.contains('^') && !inputDisplayedFormula!!.contains('%')) {
|
||||||
inputDisplayedFormula += getSign(operation)
|
inputDisplayedFormula += getSign(operation)
|
||||||
}else{
|
} else {
|
||||||
moreOperationsInRaw = true
|
moreOperationsInRaw = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,13 +197,13 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newValue = newValue.replace("\\.$".toRegex(), "")
|
newValue = newValue.replace("\\.$".toRegex(), "")
|
||||||
if(!newValue.contains('+' ) && !newValue.contains('-' ) && !newValue.contains('*' ) && !newValue.contains('/' ) && !newValue.contains('%' ) && !newValue.contains('^' ) ){
|
if (!newValue.contains('+') && !newValue.contains('-') && !newValue.contains('*') && !newValue.contains('/') && !newValue.contains('%') && !newValue.contains('^')) {
|
||||||
newValue = formatString(newValue)
|
newValue = formatString(newValue)
|
||||||
}
|
}
|
||||||
setValue(newValue)
|
setValue(newValue)
|
||||||
if(newValue!="0") {
|
if (newValue != "0") {
|
||||||
inputDisplayedFormula = newValue
|
inputDisplayedFormula = newValue
|
||||||
}else{
|
} else {
|
||||||
inputDisplayedFormula = ""
|
inputDisplayedFormula = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||||||
resetValues()
|
resetValues()
|
||||||
setValue("0")
|
setValue("0")
|
||||||
setFormula("")
|
setFormula("")
|
||||||
inputDisplayedFormula=""
|
inputDisplayedFormula = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleEquals() {
|
fun handleEquals() {
|
||||||
@ -224,7 +224,7 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||||||
if (lastKey != DIGIT)
|
if (lastKey != DIGIT)
|
||||||
return
|
return
|
||||||
|
|
||||||
displayedNumber = displayedNumber!!.substring(displayedNumber!!.indexOfAny(operations,0,false) + 1)
|
displayedNumber = displayedNumber!!.substring(displayedNumber!!.indexOfAny(operations, 0, false) + 1)
|
||||||
secondValue = getDisplayedNumberAsDouble()
|
secondValue = getDisplayedNumberAsDouble()
|
||||||
calculateResult()
|
calculateResult()
|
||||||
lastKey = EQUALS
|
lastKey = EQUALS
|
||||||
@ -234,16 +234,16 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||||||
private fun decimalClicked() {
|
private fun decimalClicked() {
|
||||||
var value = displayedNumber
|
var value = displayedNumber
|
||||||
if (!value!!.contains(".")) {
|
if (!value!!.contains(".")) {
|
||||||
if(value.toString().equals("0")){
|
if (value.toString() == "0") {
|
||||||
inputDisplayedFormula = "0."
|
inputDisplayedFormula = "0."
|
||||||
}else{
|
} else {
|
||||||
|
inputDisplayedFormula += "."
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
value = displayedNumber!!.substring(displayedNumber!!.indexOfAny(operations, 0, false) + 1)
|
||||||
|
if (!value.contains(".")) {
|
||||||
inputDisplayedFormula += "."
|
inputDisplayedFormula += "."
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
value = displayedNumber!!.substring(displayedNumber!!.indexOfAny(operations,0,false) + 1)
|
|
||||||
if (!value!!.contains(".")) {
|
|
||||||
inputDisplayedFormula += "."
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setValue(inputDisplayedFormula!!)
|
setValue(inputDisplayedFormula!!)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user