Skip to content

Commit

Permalink
fix issue where pressing a number or an operator after the following …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
jairrab committed Sep 25, 2020
1 parent f7923ea commit 4db60df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand All @@ -19,7 +19,7 @@ allprojects {
}

group 'com.github.jairrab.calc'
version "3.1.0"
version "3.1.1"


java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}

Expand Down

0 comments on commit 4db60df

Please sign in to comment.