Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.9.4 #142

Merged
merged 7 commits into from
Sep 10, 2022
Merged

0.9.4 #142

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make fields final
  • Loading branch information
ctongfei committed Sep 10, 2022
commit a197554813323702eb27848670fd5fb10dbcc997
9 changes: 6 additions & 3 deletions src/main/java/me/tongfei/progressbar/ProgressBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
*/
public class ProgressBar implements AutoCloseable {

private ProgressState progress;
private ProgressUpdateAction action;
private ScheduledFuture<?> scheduledTask;
private final ProgressState progress;
private final ProgressUpdateAction action;
private final ScheduledFuture<?> scheduledTask;

/**
* Creates a progress bar with the specific taskName name and initial maximum value.
Expand Down Expand Up @@ -114,7 +114,9 @@ public ProgressBar stepBy(long n) {
* @param n New progress value
*/
public ProgressBar stepTo(long n) {
boolean back = n < progress.current;
progress.stepTo(n);
if (back) action.forceRefresh(); // fix #124
return this;
}

Expand Down Expand Up @@ -159,6 +161,7 @@ public ProgressBar resume() {
/** Resets the progress bar to its initial state (where progress equals to 0). */
public ProgressBar reset() {
progress.reset();
action.forceRefresh(); // force refresh, fixing #124
return this;
}

Expand Down