public static class Updater {\r
private final TGStatusMonitor monitor;\r
private final int total;\r
- private int percentage;\r
+ private int low;\r
+ private int high;\r
+ private int current;\r
private int worked;\r
\r
- public Updater(TGStatusMonitor monitor, int total) {\r
+ public Updater(TGStatusMonitor monitor, int lowPercentage, int highPercentage, int totalWork) {\r
this.monitor = monitor;\r
- this.total = total;\r
+ this.low = lowPercentage;\r
+ this.high = highPercentage;\r
+ this.total = totalWork;\r
}\r
\r
public int worked(int work) {\r
worked += work;\r
- return percentage = updatePercentage(monitor, percentage, worked, total);\r
+ return current = updatePercentage(monitor, low, high, current, worked, total);\r
}\r
}\r
\r
- public static int updatePercentage(TGStatusMonitor monitor, int oldPercentage, int done, int total) {\r
- int current = (100 * done) / total;\r
- if (current > oldPercentage) {\r
+ public static int updatePercentage(TGStatusMonitor monitor, int low, int high, int oldPercentage, int done, int total) {\r
+ int range = high - low;\r
+ int current = low + (range * done) / total;\r
+ if (current != oldPercentage) {\r
oldPercentage = current;\r
if (monitor != null) \r
monitor.status(oldPercentage);\r