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 bb858d93..db0ded8a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt @@ -77,7 +77,7 @@ class MainActivity : SimpleActivity(), Calculator { - calc = CalculatorImpl(this, applicationContext,decimalSeparator, groupingSeparator, savedRes, savedPreviousCalculation, savedLastKey, savedLastOperation, savedBaseValue, savedSecondValue) + calc = CalculatorImpl(this, applicationContext,decimalSeparator, groupingSeparator, savedRes, savedPreviousCalculation, savedLastKey, savedLastOperation, savedBaseValue, savedSecondValue, savedInputDisplayedFormula) //============================================================ @@ -291,9 +291,8 @@ class MainActivity : SimpleActivity(), Calculator { bundle.putString("savedLastKey", calc.lastKey) bundle.putString("savedLastOperation", calc.lastOperation) bundle.putDouble("savedBaseValue", calc.baseValue) - bundle.putDouble("savedSecondValue", calc.getSecondValue()) + bundle.putDouble("savedSecondValue", calc.getSecondValueV2()) bundle.putString("savedInputDisplayedFormula", calc.inputDisplayedFormula) - } //============================================================ } 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 eaa703f0..ba3f7710 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt @@ -24,12 +24,13 @@ class CalculatorImpl( aSecondValue: Double = 0.0, aInputDisplayedFormula: String = "0" + //============================================================ ) { private var callback: Calculator? = calculator //============================================================ - // Trying Fix it + // Trying Fix it` public var mResult = aRes public var previousCalculation = aSavedLastOperation public var lastKey = aLastKey @@ -227,7 +228,10 @@ class CalculatorImpl( public fun getSecondValue(): Double { val valueToCheck = inputDisplayedFormula.trimStart('-').removeGroupSeparator() + Log.v("VALUEToCheck GETSV :", valueToCheck) + var value = valueToCheck.substring(valueToCheck.indexOfAny(operations) + 1) + Log.v("VALUE GETSV :", value) if (value == "") { value = "0" } @@ -309,6 +313,8 @@ class CalculatorImpl( //mResult = result.format() Log.v("CalculResult", result.format()) + Log.v("BASEVALUE CR :", baseValue.toString()) + Log.v("SECONDVALUE CR :", secondValue.toString()) //============================================================ showNewResult(result.format()) @@ -366,6 +372,8 @@ class CalculatorImpl( private fun showNewFormula(value: String) { //============================================================ previousCalculation = value; + Log.v("BASEVALUE SHOWNF :", baseValue.toString()) + Log.v("SECONDVALUE SHOWNF:", secondValue.toString()) //============================================================ callback!!.showNewFormula(value, context) } @@ -466,4 +474,10 @@ class CalculatorImpl( private fun Double.format() = formatter.doubleToString(this) private fun String.removeGroupSeparator() = formatter.removeGroupingSeparator(this) + + public fun getSecondValueV2() : Double + { + return this.secondValue + } + }