mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-20 00:06:36 +00:00
Make progress less jittery
This commit is contained in:
@@ -445,7 +445,7 @@ final class BrowserFileListComp extends SimpleComp {
|
||||
if (path.getRawFileEntry().resolved().getKind() == FileKind.DIRECTORY) {
|
||||
setText("");
|
||||
} else {
|
||||
setText(byteCount(fileSize.longValue()));
|
||||
setText(byteCount(fileSize.longValue(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ public class BrowserStatusBarComp extends SimpleComp {
|
||||
var transferredCount = PlatformThread.sync(Bindings.createStringBinding(
|
||||
() -> {
|
||||
return HumanReadableFormat.byteCount(
|
||||
model.getProgress().getValue().getTransferred());
|
||||
model.getProgress().getValue().getTransferred(), false);
|
||||
},
|
||||
model.getProgress()));
|
||||
var allCount = PlatformThread.sync(Bindings.createStringBinding(
|
||||
() -> {
|
||||
return HumanReadableFormat.byteCount(
|
||||
model.getProgress().getValue().getTotal());
|
||||
model.getProgress().getValue().getTotal(), true);
|
||||
},
|
||||
model.getProgress()));
|
||||
var progressComp = new LabelComp(Bindings.createStringBinding(
|
||||
|
||||
@@ -16,7 +16,7 @@ public final class HumanReadableFormat {
|
||||
public static final DateTimeFormatter DAY_OF_WEEK = DateTimeFormatter.ofPattern("EEE");
|
||||
public static final DateTimeFormatter HOUR_MINUTE = DateTimeFormatter.ofPattern("HH:mm");
|
||||
|
||||
public static String byteCount(long bytes) {
|
||||
public static String byteCount(long bytes, boolean precise) {
|
||||
if (-1024 < bytes && bytes < 1024) {
|
||||
return bytes + " B";
|
||||
}
|
||||
@@ -25,7 +25,8 @@ public final class HumanReadableFormat {
|
||||
bytes /= 1024;
|
||||
ci.next();
|
||||
}
|
||||
return String.format("%.1f %cB", bytes / 1024.0, ci.current());
|
||||
var f = precise ? "%.1f" : "%.0f";
|
||||
return String.format(f + " %cB", bytes / 1024.0, ci.current());
|
||||
}
|
||||
|
||||
public static String date(LocalDateTime x) {
|
||||
|
||||
Reference in New Issue
Block a user