mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-08-09 04:43:05 +02:00
Allow amounts up to 4 digits without abbreviation
This commit is contained in:
@@ -1438,13 +1438,14 @@ fun showCount(count: Int?): String {
|
|||||||
return when {
|
return when {
|
||||||
count >= 1000000000 -> "${(count / 1000000000f).roundToInt()}G"
|
count >= 1000000000 -> "${(count / 1000000000f).roundToInt()}G"
|
||||||
count >= 1000000 -> "${(count / 1000000f).roundToInt()}M"
|
count >= 1000000 -> "${(count / 1000000f).roundToInt()}M"
|
||||||
count >= 1000 -> "${(count / 1000f).roundToInt()}k"
|
count >= 10000 -> "${(count / 1000f).roundToInt()}k"
|
||||||
else -> "$count"
|
else -> "$count"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val OneGiga = BigDecimal(1000000000)
|
val OneGiga = BigDecimal(1000000000)
|
||||||
val OneMega = BigDecimal(1000000)
|
val OneMega = BigDecimal(1000000)
|
||||||
|
val TenKilo = BigDecimal(10000)
|
||||||
val OneKilo = BigDecimal(1000)
|
val OneKilo = BigDecimal(1000)
|
||||||
|
|
||||||
var dfG: DecimalFormat = DecimalFormat("#.0G")
|
var dfG: DecimalFormat = DecimalFormat("#.0G")
|
||||||
@@ -1457,9 +1458,9 @@ fun showAmount(amount: BigDecimal?): String {
|
|||||||
if (amount.abs() < BigDecimal(0.01)) return ""
|
if (amount.abs() < BigDecimal(0.01)) return ""
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
amount >= OneGiga -> dfG.format(amount.div(OneGiga).setScale(1, RoundingMode.HALF_UP))
|
amount >= OneGiga -> dfG.format(amount.div(OneGiga).setScale(0, RoundingMode.HALF_UP))
|
||||||
amount >= OneMega -> dfM.format(amount.div(OneMega).setScale(1, RoundingMode.HALF_UP))
|
amount >= OneMega -> dfM.format(amount.div(OneMega).setScale(0, RoundingMode.HALF_UP))
|
||||||
amount >= OneKilo -> dfK.format(amount.div(OneKilo).setScale(1, RoundingMode.HALF_UP))
|
amount >= TenKilo -> dfK.format(amount.div(OneKilo).setScale(0, RoundingMode.HALF_UP))
|
||||||
else -> dfN.format(amount)
|
else -> dfN.format(amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -53,6 +53,7 @@ import com.vitorpamplona.amethyst.ui.navigation.Route
|
|||||||
import com.vitorpamplona.amethyst.ui.note.OneGiga
|
import com.vitorpamplona.amethyst.ui.note.OneGiga
|
||||||
import com.vitorpamplona.amethyst.ui.note.OneKilo
|
import com.vitorpamplona.amethyst.ui.note.OneKilo
|
||||||
import com.vitorpamplona.amethyst.ui.note.OneMega
|
import com.vitorpamplona.amethyst.ui.note.OneMega
|
||||||
|
import com.vitorpamplona.amethyst.ui.note.TenKilo
|
||||||
import com.vitorpamplona.amethyst.ui.note.UserReactionsRow
|
import com.vitorpamplona.amethyst.ui.note.UserReactionsRow
|
||||||
import com.vitorpamplona.amethyst.ui.note.UserReactionsViewModel
|
import com.vitorpamplona.amethyst.ui.note.UserReactionsViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.note.showAmount
|
import com.vitorpamplona.amethyst.ui.note.showAmount
|
||||||
@@ -289,7 +290,7 @@ fun showAmountAxis(amount: BigDecimal?): String {
|
|||||||
return when {
|
return when {
|
||||||
amount >= OneGiga -> dfG.format(amount.div(OneGiga).setScale(0, RoundingMode.HALF_UP))
|
amount >= OneGiga -> dfG.format(amount.div(OneGiga).setScale(0, RoundingMode.HALF_UP))
|
||||||
amount >= OneMega -> dfM.format(amount.div(OneMega).setScale(0, RoundingMode.HALF_UP))
|
amount >= OneMega -> dfM.format(amount.div(OneMega).setScale(0, RoundingMode.HALF_UP))
|
||||||
amount >= OneKilo -> dfK.format(amount.div(OneKilo).setScale(0, RoundingMode.HALF_UP))
|
amount >= TenKilo -> dfK.format(amount.div(OneKilo).setScale(0, RoundingMode.HALF_UP))
|
||||||
else -> dfN.format(amount)
|
else -> dfN.format(amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user