Android Progress Dialog Create stallWithProgressDialog(Context context, String title, String msg, boolean indeter, boolean cancelable, int stallTime)

Here you can find the source of stallWithProgressDialog(Context context, String title, String msg, boolean indeter, boolean cancelable, int stallTime)

Description

Function to stall the UI for given time.

Parameter

Parameter Description
context a parameter
title title of the progressDialog
msg message of the progressDialog
indeter if true progress percentage is not shown
cancelable dialog cancelable boolean
stallTime time to pause the UI

Declaration

public static void stallWithProgressDialog(Context context,
        String title, String msg, boolean indeter, boolean cancelable,
        int stallTime) 

Method Source Code

//package com.java2s;

import android.app.ProgressDialog;
import android.content.Context;

public class Main {
    /**/*from www .  ja  va  2 s  .c  o  m*/
     * Function to stall the UI for given time. Used when server request
     * frequncy is too high.
     * 
     * @param context
     * @param title
     *            title of the progressDialog
     * @param msg
     *            message of the progressDialog
     * @param indeter
     *            if true progress percentage is not shown
     * @param cancelable
     *            dialog cancelable boolean
     * @param stallTime
     *            time to pause the UI
     */
    public static void stallWithProgressDialog(Context context,
            String title, String msg, boolean indeter, boolean cancelable,
            int stallTime) {
        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 {
                    Thread.sleep(stalltime);
                } catch (Exception e) {
                }
                ringProgressDialog.dismiss();
            }
        }).start();
    }
}

Related

  1. showProgressDialog(Context mContext, CharSequence processMessage)
  2. showProgressDialog(Context c, String title, String msg)
  3. hideProgressDialog()
  4. showProgressDialog(String msg)