Fixed number formatting that looks weird in grid view

This commit is contained in:
raoulvdberge
2017-08-07 23:07:07 +02:00
parent 1a3e66cc72
commit 38ec6ea613

View File

@@ -44,10 +44,22 @@ public final class RenderUtils {
} }
public static String formatQuantity(int qty) { public static String formatQuantity(int qty) {
if (qty >= 1000000) { if (qty >= 1_000_000) {
return QUANTITY_FORMATTER.format((float) qty / 1000000F) + "M"; float qtyShort = (float) qty / 1_000_000F;
if (qty >= 100_000_000) {
qtyShort = Math.round(qtyShort); // XXX.XM looks weird.
}
return QUANTITY_FORMATTER.format(qtyShort) + "M";
} else if (qty >= 1000) { } else if (qty >= 1000) {
return QUANTITY_FORMATTER.format((float) qty / 1000F) + "K"; float qtyShort = (float) qty / 1000F;
if (qty >= 100_000) {
qtyShort = Math.round(qtyShort); // XXX.XK looks weird.
}
return QUANTITY_FORMATTER.format(qtyShort) + "K";
} }
return String.valueOf(qty); return String.valueOf(qty);