From: Niki Roo Date: Sun, 12 Mar 2017 18:50:03 +0000 (+0100) Subject: Version 1.4.1: Progress fixes X-Git-Tag: fanfix-3.0.1~29^2~264 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=cac67ebc7e930733b55a381aa72e44c41eac224a;p=fanfix.git Version 1.4.1: Progress fixes --- diff --git a/VERSION b/VERSION index 88c5fb8..347f583 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.0 +1.4.1 diff --git a/changelog b/changelog index 4a8514d..3cc63ad 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,10 @@ +Version 1.4.1 +------------- + +Progress + Better handling of min==max case + New methods .done() and .add(int step) + Version 1.4.0 ------------- diff --git a/src/be/nikiroo/utils/Progress.java b/src/be/nikiroo/utils/Progress.java index b6137f1..5ee3221 100644 --- a/src/be/nikiroo/utils/Progress.java +++ b/src/be/nikiroo/utils/Progress.java @@ -227,6 +227,18 @@ public class Progress { } } + /** + * Add some value to the current progression of this {@link Progress}. + * + * @param step + * the amount to add + */ + public void add(int step) { + synchronized (getLock()) { + setProgress(localProgress + step); + } + } + /** * Check if the action corresponding to this {@link Progress} is done (i.e., * if its progress value == its max value). @@ -237,6 +249,13 @@ public class Progress { return progress >= max; } + /** + * Mark the {@link Progress} as done by setting its value to max. + */ + public void done() { + setProgress(getMax()); + } + /** * Get the total progress value (including the optional children * {@link Progress}) on a 0.0 to 1.0 scale. @@ -244,6 +263,10 @@ public class Progress { * @return the progress */ public double getRelativeProgress() { + if (max == min) { + return 1; + } + return (((double) progress) / (max - min)); }