Issues #716,#717,#718 Proxy dialog improvements

This commit is contained in:
Jindra Petřík
2014-11-17 22:37:01 +01:00
parent b75ebeae81
commit 917c56e549
9 changed files with 529 additions and 174 deletions

View File

@@ -872,4 +872,16 @@ public class Helper {
}
return ret;
}
public static String byteCountStr(long bytes, boolean si) {
int unit = si ? 1000 : 1024;
if (bytes < unit) {
return bytes + " B";
}
int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
}
}