From 4db60dff1399d16fad2f591fa3b6523c88307e8b Mon Sep 17 00:00:00 2001 From: Jay Barria Date: Fri, 25 Sep 2020 08:24:07 +0800 Subject: [PATCH] fix issue where pressing a number or an operator after the following sequence throws an exception: 1 / 0 = Pressing a number after the above sequence should replace the `=` sign with the number or operator, e.g. (A) `1 / 0 / =` Press `2` after sequence (A) `1 / 0 / 2` Press `+` after sequence (A) `1 / 0 +` The library will still call a CalculatorUpdate of`DivideByZeroException` in this case that the library user can handle --- build.gradle | 4 ++-- .../jairrab/calc/lib/controls/outputs/DisplayManager.kt | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 541ae64..59d48e1 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { * Use plugin 'kotlin' if importing this project into Android Studio * Use plugin 'org.jetbrains.kotlin.jvm' version '1.3.61' to build library */ -// id 'kotlin' + //id 'kotlin' id 'org.jetbrains.kotlin.jvm' version '1.4.10' } @@ -19,7 +19,7 @@ allprojects { } group 'com.github.jairrab.calc' -version "3.1.0" +version "3.1.1" java { diff --git a/src/main/kotlin/com/github/jairrab/calc/lib/controls/outputs/DisplayManager.kt b/src/main/kotlin/com/github/jairrab/calc/lib/controls/outputs/DisplayManager.kt index 384a602..8a349a3 100644 --- a/src/main/kotlin/com/github/jairrab/calc/lib/controls/outputs/DisplayManager.kt +++ b/src/main/kotlin/com/github/jairrab/calc/lib/controls/outputs/DisplayManager.kt @@ -42,6 +42,10 @@ class DisplayManager private constructor( } catch (e: DivideByZeroException) { LOG.warning("Divide by zero error") listener?.onCalculatorUpdate(Error.DivideByZero(button.tag, entries)) + + if (button == CalculatorButton.EQUALS) { + entriesManager.removeLastEntry() + } } }