Fixed - Realtime Calculation Update
This commit is contained in:
@@ -150,7 +150,7 @@ class MainActivity : AppCompatActivity(), DialogActionsCallback, DialogUtil.Dial
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun clearDisplay() {
|
private fun clearDisplay() {
|
||||||
currentExpression = ""
|
currentExpression = "0"
|
||||||
binding.total.text = ""
|
binding.total.text = ""
|
||||||
lastWasOperator = false
|
lastWasOperator = false
|
||||||
lastWasPercent = false
|
lastWasPercent = false
|
||||||
@@ -335,13 +335,17 @@ class MainActivity : AppCompatActivity(), DialogActionsCallback, DialogUtil.Dial
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (currentExpression.isEmpty() ||
|
if (currentExpression.isEmpty()) {
|
||||||
(isOperator(currentExpression.last().toString()) && currentExpression.last() != '%')) {
|
|
||||||
binding.total.text = ""
|
binding.total.text = ""
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var processedExpression = currentExpression.replace("×", "*")
|
var processedExpression = currentExpression.replace("×", "*")
|
||||||
|
|
||||||
|
if (isOperator(processedExpression.last().toString())) {
|
||||||
|
processedExpression = processedExpression.substring(0, processedExpression.length - 1)
|
||||||
|
}
|
||||||
|
|
||||||
if (processedExpression.contains("%")) {
|
if (processedExpression.contains("%")) {
|
||||||
processedExpression = preprocessExpression(processedExpression)
|
processedExpression = preprocessExpression(processedExpression)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
android:gravity="end|bottom"
|
android:gravity="end|bottom"
|
||||||
android:autoSizeTextType="uniform"
|
android:autoSizeTextType="uniform"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:text=""
|
android:text="0"
|
||||||
android:textSize="70sp"
|
android:textSize="70sp"
|
||||||
tools:ignore="Suspicious0dp" />
|
tools:ignore="Suspicious0dp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user