From 71ceccedd9c6b7eb64c558dc9203876604a0f3ef Mon Sep 17 00:00:00 2001 From: KM Tong Date: Fri, 16 Jul 2021 17:16:11 +0800 Subject: [PATCH] close progressbar will force update UI --- src/main/java/me/tongfei/progressbar/ProgressBar.java | 1 + .../java/me/tongfei/progressbar/ProgressUpdateAction.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/main/java/me/tongfei/progressbar/ProgressBar.java b/src/main/java/me/tongfei/progressbar/ProgressBar.java index ecd23bd..9e4f6ff 100644 --- a/src/main/java/me/tongfei/progressbar/ProgressBar.java +++ b/src/main/java/me/tongfei/progressbar/ProgressBar.java @@ -163,6 +163,7 @@ public void close() { scheduledTask.cancel(false); progress.kill(); try { + action.setForceRefresh(); Util.executor.schedule(action, 0, TimeUnit.NANOSECONDS).get(); } catch (InterruptedException | ExecutionException e) { /* NOOP */ } } diff --git a/src/main/java/me/tongfei/progressbar/ProgressUpdateAction.java b/src/main/java/me/tongfei/progressbar/ProgressUpdateAction.java index ec71d74..dc0fa2d 100644 --- a/src/main/java/me/tongfei/progressbar/ProgressUpdateAction.java +++ b/src/main/java/me/tongfei/progressbar/ProgressUpdateAction.java @@ -30,6 +30,10 @@ private void refresh() { // else do nothing: only print when actual progress is made (#91). } + public void setForceRefresh() { + last = -1; + } + public void run() { if (!progress.paused) refresh(); if (!progress.alive) {