Android Utililty Methods Progress Dialog Create

List of utility methods to do Progress Dialog Create

Description

The list of methods to do Progress Dialog Create are organized into topic(s).

Method

voidstallWithProgressDialog(Context context, String title, String msg, boolean indeter, boolean cancelable, int stallTime)
Function to stall the UI for given time.
final ProgressDialog ringProgressDialog = ProgressDialog.show(
        context, title, msg, indeter);
ringProgressDialog.setCancelable(cancelable);
final int stalltime = stallTime;
new Thread(new Runnable() {
    @Override
    public void run() {
        try {
...
ProgressDialogshowProgressDialog(Context mContext, CharSequence processMessage)
show Progress Dialog
ProgressDialog pDlg = new ProgressDialog(mContext);
pDlg.setMessage(processMessage);
pDlg.setProgressDrawable(WallpaperManager.getInstance(mContext)
        .getDrawable());
pDlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pDlg.setCancelable(false);
return pDlg;
ProgressDialogshowProgressDialog(Context c, String title, String msg)
show Progress Dialog
return ProgressDialog.show(c, title, msg, true);
voidhideProgressDialog()
This method will hide existing progress dialog.
It will not throw any Exception if there is no progress dialog on the screen and can also be called from non UI threads.
mSmartAndroidActivity.runOnUiThread(new Runnable() {
    @Override
    public void run() {
        try {
            if (progress.isShowing())
                progress.dismiss();
        } catch (Throwable e) {
});
voidshowProgressDialog(String msg)
This method will show the progress dialog with given message in the given activity's context.
The progress dialog will be non cancellable by default.
progressMsg = msg;
mSmartAndroidActivity.runOnUiThread(new Runnable() {
    public void run() {
        progress = ProgressDialog.show(mSmartAndroidActivity, "",
                progressMsg);
});
voidshowProgressDialog(String msg, final boolean isCancellable)
This method will show the progress dialog with given message in the given activity's context.
The progress dialog can be set cancellable by passing appropriate flag in parameter.
progressMsg = msg;
mSmartAndroidActivity.runOnUiThread(new Runnable() {
    public void run() {
        progress = ProgressDialog.show(mSmartAndroidActivity, "",
                progressMsg);
        progress.setCancelable(isCancellable);
});
...
voidshowProgressBar(ProgressDialog progressBar, String message)
show Progress Bar
progressBar.setCancelable(false);
progressBar.setMessage(message);
progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressBar.show();