From 83f3af340ffd9af29618647dd650c6c7b48e7703 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 7 Apr 2023 16:55:15 -0400 Subject: [PATCH] Uses Kotlin's rounding function instead of java --- .../com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt index 3192a1934..e90641a38 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt @@ -63,6 +63,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.math.BigDecimal import java.math.RoundingMode +import kotlin.math.roundToInt @Composable fun ReactionsRow(baseNote: Note, accountViewModel: AccountViewModel) { @@ -604,9 +605,9 @@ fun showCount(count: Int?): String { if (count == 0) return "" return when { - count >= 1000000000 -> "${Math.round(count / 1000000000f)}G" - count >= 1000000 -> "${Math.round(count / 1000000f)}M" - count >= 1000 -> "${Math.round(count / 1000f)}k" + count >= 1000000000 -> "${(count / 1000000000f).roundToInt()}G" + count >= 1000000 -> "${(count / 1000000f).roundToInt()}M" + count >= 1000 -> "${(count / 1000f).roundToInt()}k" else -> "$count" } }