mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-08-22 10:09:39 +00:00
Improve scale display
This commit is contained in:
parent
9f526e8e8f
commit
9f11db8e06
@ -191,14 +191,20 @@ public final class Localization {
|
||||
|
||||
final double value = (double) count;
|
||||
if (count >= 1000000000) {
|
||||
final double shortenedValue = value / 1000000000;
|
||||
final int scale = shortenedValue >= 100 ? 0 : 1;
|
||||
return context.getString(R.string.short_billion,
|
||||
localizeNumber(round(value / 1000000000)));
|
||||
localizeNumber(round(shortenedValue, scale)));
|
||||
} else if (count >= 1000000) {
|
||||
final double shortenedValue = value / 1000000;
|
||||
final int scale = shortenedValue >= 100 ? 0 : 1;
|
||||
return context.getString(R.string.short_million,
|
||||
localizeNumber(round(value / 1000000)));
|
||||
localizeNumber(round(shortenedValue, scale)));
|
||||
} else if (count >= 1000) {
|
||||
final double shortenedValue = value / 1000;
|
||||
final int scale = shortenedValue >= 100 ? 0 : 1;
|
||||
return context.getString(R.string.short_thousand,
|
||||
localizeNumber(round(value / 1000, 0)));
|
||||
localizeNumber(round(shortenedValue, scale)));
|
||||
} else {
|
||||
return localizeNumber(value);
|
||||
}
|
||||
@ -416,10 +422,6 @@ public final class Localization {
|
||||
}
|
||||
}
|
||||
|
||||
private static double round(final double value) {
|
||||
return round(value, 1);
|
||||
}
|
||||
|
||||
private static double round(final double value, final int scale) {
|
||||
return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user