public class ProgressReporter extends Object
IProgressListener
.
The reported progress of a task ranges from 0-100, but the task can be
segmented into smaller pieces using startSegment(int)
and
endSegment(int[])
, and segments can be nested.
Here's an example in action; when finished the overall task progress will be at 60.
prog.setProgress(20); { final int restore = prog.startSegment(40); for (int i = 0; i < N; i++) { prog.setProgress(i, N); ... } prog.endSegment(restore); }
Constructor and Description |
---|
ProgressReporter(int id)
Create a new task with the given identifier whose progress will be
reported to the given listener.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(IProgressListener listener)
Add given listener to watch for progress events.
|
void |
endSegment(int[] lastRange)
End the current segment.
|
void |
finish()
Report this entire task as being finished.
|
void |
setProgress(int progress)
Set the progress of the currently active segment.
|
void |
setProgress(int progress,
CharSequence title)
Set the progress of the currently active segment.
|
void |
setProgress(int n,
int m)
Set the fractional progress of the currently active segment.
|
void |
setProgress(int n,
int m,
CharSequence title)
Set the fractional progress of the currently active segment.
|
void |
start()
Report this entire task as being started.
|
int[] |
startSegment(int size)
Start a new inner segment that will contribute the given range towards
the currently active segment.
|
public ProgressReporter(int id)
public void addListener(IProgressListener listener)
public void setProgress(int progress)
progress
- Segment progress between 0-100.public void setProgress(int progress, CharSequence title)
progress
- Segment progress between 0-100.public void setProgress(int n, int m)
public void setProgress(int n, int m, CharSequence title)
public int[] startSegment(int size)
endSegment(int[])
when finished.public void endSegment(int[] lastRange)
public void start()
public void finish()