Skip to content

Commit 2647010

Browse files
authored
fix: use proper separator when applying temperature limits (#115)
* fix: use proper separator when applying temperature limits * fix: recalculate bottom value on clear
1 parent 2d63b7a commit 2647010

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

app/src/main/kotlin/org/fossify/math/views/ConverterView.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class ConverterView @JvmOverloads constructor(
141141

142142
fun clear() {
143143
binding.topUnitText.text = "0"
144-
binding.bottomUnitText.text = "0"
144+
updateBottomValue()
145145
}
146146

147147
fun deleteCharacter() {
@@ -381,11 +381,17 @@ class ConverterView @JvmOverloads constructor(
381381

382382
return when (topUnit?.key) {
383383
TemperatureConverter.Unit.Celsius.key -> {
384-
if (numericValue < BigDecimal("-273.15")) "-273.15" else value
384+
val minCelsius = BigDecimal("-273.15")
385+
if (numericValue < minCelsius) formatter.bigDecimalToString(minCelsius) else value
385386
}
386387

387388
TemperatureConverter.Unit.Fahrenheit.key -> {
388-
if (numericValue < BigDecimal("-459.67")) "-459.67" else value
389+
val minFahrenheit = BigDecimal("-459.67")
390+
if (numericValue < minFahrenheit) {
391+
formatter.bigDecimalToString(minFahrenheit)
392+
} else {
393+
value
394+
}
389395
}
390396

391397
TemperatureConverter.Unit.Kelvin.key,

0 commit comments

Comments
 (0)