-
-
Notifications
You must be signed in to change notification settings - Fork 18
SimpleProgressDialog
extends CustomViewDialog, Full API reference, added in v3.4
A dialog showing a progress
The progress is indeterminate by default, but can be updated either before the dialog is shown or while it is being shown.
In addition, an AsyncTask can easily be connected to the dialog, such that the progress and state is automatically synced with the task.
By default, a cancel button is shown, but the dialog can not be dismissed by (accidentally) clicking outside it or via the back button. This button can be removed via .neut(null).
The dialog is meant to be dismissed by calling .dismiss(), but an auto-dismiss option exists.
SimpleProgressDialog.bar()
.title(R.string.login)
.msg(R.string.creating_user_profile_wait)
.show(this, PROGRESS_DIALOG);// use this to access the dialog after rotation changes
FragmentManager fm = getSupportFragmentManager();
SimpleProgressDialog dialog = (SimpleProgressDialog)
fm.findFragmentByTag(PROGRESS_DIALOG);
dialog.updateProgress(13, 100);
dialog.updateInfoText("Working…");
dialog.dismiss();More examples can be found in the testApp
-
Type (bar/circle)
SimpleProgressDialog.bar()
SimpleProgressDialog.indeterminateCircle()
.type(Type type)
Please note that the circle type can only show an indeterminate progress -
Percentage indicator "00%" below bar/inside circle
(shown by default for bar type)
.percentage(boolean visible)
See also CustomViewDialog
These methods can be called either before the dialog is shown or while it is being shown.
Progress
.updateProgress(int progress)
.updateProgress(int progress, int max)
.updateMax(int max)
.updateSecondaryProgress(int progress)
.updateIndeterminate()
.updateFinished()
Text
.updateProgressText(String text) for a short text, e.g. 5% or 8MB (by default, this shows the progress in percent unless manually set)
.updateInfoText(String text) for a longer text, e.g. "Loading data…" or "5 seconds left"
Derive a task from SimpleProgressTask.
static class MyProgressTask extends SimpleProgressTask<Void, Integer, Void> {
@Override
protected Void doInBackground(Void... voids) {
publishProgress(-1); // Indeterminate
publishProgress(10); // 10% progress
publishProgress(100, 500); // 100/500 = 20% progress
publishProgress(20, 100, 40); // 20% primary and 40% secondary progress
// ... you can also set text via publishProgess(...), see javadoc for details
}
// if required, the full spectra of `mDialog.updateXXX(...)` methods can be called from a custom `onProgressUpdate` implementation
}and link it to the dialog:
MyTask task = new MyTask();
task.execute();
SimpleProgressDialog.bar()
.title("...")
.msg("...")
.task(task, isCancelable, isAutoDismissed) // optional cancel button and auto-dismiss functionality
.show(this);If isCancelable is set and the cancel button is pressed, the task is canceled with mayInterruptIfRunning=false, so make sure to frequently check for ìsCancelled() in your tasks doInBackground method.
If isAutoDismissed is set, the dialog will be dismissed once the task is finished and the onResult method will be called with which=SimpleProgressDialog.COMPLETED.
See SimpleDialog and note the special which=SimpleProgressDialog.COMPLETED for auto-dismissed AsyncTasks.
Javadoc API
Screenshot gallery
Styling dialogs with themes
Fullscreen dialogs
SimpleDialog
CustomViewDialog
CustomListDialog
SimpleCheckDialog
SimpleColorDialog
SimpleColorWheelDialog
SimpleDateDialog
SimpleEMailDialog
SimpleFormDialog
SimpleImageDialog
SimpleInputDialog
SimpleListDialog
SimplePinDialog
SimpleProgressDialog
SimpleTimeDialog