Example usage for android.app ProgressDialog setIndeterminate

List of usage examples for android.app ProgressDialog setIndeterminate

Introduction

In this page you can find the example usage for android.app ProgressDialog setIndeterminate.

Prototype

public void setIndeterminate(boolean indeterminate) 

Source Link

Document

Change the indeterminate mode for this ProgressDialog.

Usage

From source file:Main.java

public static ProgressDialog progressDialog(Context context, String message) {
    ProgressDialog dialog = new ProgressDialog(context);
    if (message != null) {
        dialog.setMessage(message);/*w w  w. j  a  v a 2s. c  o m*/
    }
    dialog.setIndeterminate(true);
    dialog.setCancelable(true);
    return dialog;
}

From source file:Main.java

public static ProgressDialog showProgressDialog(Context context, String msg) {
    ProgressDialog progressDialog = new ProgressDialog(context);
    if (!TextUtils.isEmpty(msg))
        progressDialog.setMessage(msg);/*from  ww w  .  j a  va 2 s. c o  m*/
    progressDialog.setIndeterminate(true);
    progressDialog.setCancelable(false);
    progressDialog.show();
    return progressDialog;
}

From source file:Main.java

public static ProgressDialog makeProgressDialog(Context ctx) {
    ProgressDialog p = new ProgressDialog(ctx);
    p.setCancelable(false);/*w ww  .  j  a  va  2 s.co m*/
    p.setCanceledOnTouchOutside(false);
    p.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    p.setIndeterminate(true);
    return p;
}

From source file:Main.java

public static ProgressDialog showProgressDialog(Activity context, int message,
        ProgressDialog.OnCancelListener cancelListener) {
    ProgressDialog mDialog = new ProgressDialog(context);
    mDialog.setCancelable(cancelListener != null);
    mDialog.setOnCancelListener(cancelListener);
    mDialog.setMessage(context.getString(message));
    mDialog.setIndeterminate(true);
    mDialog.show();//from   w w w .  java  2  s  .  c o  m
    return mDialog;
}

From source file:Main.java

public static ProgressDialog creativeProgressBar(Context context, String comment) {
    ProgressDialog dialog = new ProgressDialog(context);
    if (comment == null)
        dialog.setMessage("Please wait while loading...");
    else/*from  w ww  .j a  va  2  s .c  o m*/
        dialog.setMessage(comment);

    dialog.setIndeterminate(true);
    dialog.setCancelable(true);
    return dialog;
}

From source file:Main.java

public static ProgressDialog getCustomProgressDialog(Context context, String content,
        boolean canceledOnTouchOutside, int dialogTheam) {
    ProgressDialog progressDialog = dialogTheam == 0 ? new ProgressDialog(context)
            : new ProgressDialog(context, dialogTheam);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setMessage(content);/*w w  w.  j  a va  2s.  c o  m*/
    progressDialog.setIndeterminate(true);
    progressDialog.setCanceledOnTouchOutside(canceledOnTouchOutside);
    return progressDialog;
}

From source file:com.android.gallery3d.ui.MenuExecutor.java

private static ProgressDialog createProgressDialog(Context context, int titleId, int progressMax) {
    ProgressDialog dialog = new ProgressDialog(context);
    dialog.setTitle(titleId);/*from  w w w.j a  v  a 2 s . c o m*/
    dialog.setMax(progressMax);
    dialog.setCancelable(false);
    dialog.setIndeterminate(false);
    if (progressMax > 1) {
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    }
    return dialog;
}

From source file:Main.java

public static ProgressDialog createProgressDialog(final Activity activity, int progressDialogTitleId,
        int progressDialogMsgId) {
    ProgressDialog progressDialog = new ProgressDialog(activity);
    if (progressDialogTitleId > 0) {
        progressDialog.setTitle(progressDialogTitleId);
    } else {//from   w ww. j ava  2  s.co m
        progressDialog.setTitle(activity.getResources().getIdentifier(PROGRESS_DIALOG_TITLE_RESOURCE, "string",
                activity.getPackageName()));
    }
    if (progressDialogMsgId > 0) {
        progressDialog.setMessage(activity.getString(progressDialogMsgId));
    } else {
        progressDialogMsgId = activity.getResources().getIdentifier(PROGRESS_DIALOG_MESSAGE_RESOURCE, "string",
                activity.getPackageName());
        progressDialog.setMessage(activity.getString(progressDialogMsgId));
    }
    progressDialog.setIndeterminate(true);
    progressDialog.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            activity.onKeyDown(keyCode, event);
            return false;
        }
    });
    // progressDialog.setInverseBackgroundForced(true);
    return progressDialog;
}

From source file:com.lostad.app.base.util.DownloadUtil.java

public static void downFileAsyn(final Activity ctx, final String upgradeUrl, final String savedPath,
        final MyCallback<Boolean> callback) {
    final ProgressDialog xh_pDialog = new ProgressDialog(ctx);
    // ?//w w  w . ja  v  a  2s . co m
    xh_pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    // ProgressDialog 
    xh_pDialog.setTitle("???");
    // ProgressDialog???
    xh_pDialog.setMessage("...");
    // ProgressDialog
    // xh_pDialog.setIcon(R.drawable.img2);
    // ProgressDialog ??? false ??
    xh_pDialog.setIndeterminate(false);
    // ProgressDialog ?
    // xh_pDialog.setProgress(100);
    // ProgressDialog ???
    xh_pDialog.setCancelable(true);
    // ProgressDialog
    xh_pDialog.show();

    new Thread() {
        public void run() {

            boolean downloadSuccess = true;
            FileOutputStream fileOutputStream = null;
            try {
                Looper.prepare();
                HttpClient client = new DefaultHttpClient();
                HttpGet get = new HttpGet(upgradeUrl);

                File f = new File(savedPath);
                if (!f.exists()) {
                    f.createNewFile();
                }

                HttpResponse response = client.execute(get);
                HttpEntity entity = response.getEntity();
                // ?
                Long length = entity.getContentLength();
                xh_pDialog.setMax(length.intValue());
                //
                InputStream is = entity.getContent();
                fileOutputStream = null;

                if (is != null && length > 0) {

                    fileOutputStream = new FileOutputStream(f);

                    byte[] buf = new byte[1024];
                    int ch = -1;
                    int count = 0;
                    while ((ch = is.read(buf)) != -1) {

                        if (xh_pDialog.isShowing()) {
                            fileOutputStream.write(buf, 0, ch);
                            // ?
                            count += ch;
                            xh_pDialog.setProgress(count);
                        } else {
                            downloadSuccess = false;
                            break;// ?
                        }
                    }

                } else {
                    callback.onCallback(false);
                }

                if (downloadSuccess && fileOutputStream != null) {
                    xh_pDialog.dismiss();
                    fileOutputStream.flush();
                    fileOutputStream.close();
                    callback.onCallback(true);// ?
                }
                Looper.loop();
            } catch (FileNotFoundException e) {
                xh_pDialog.dismiss();
                e.printStackTrace();
                callback.onCallback(false);
                xh_pDialog.dismiss();
            } catch (Exception e) {
                xh_pDialog.dismiss();
                e.printStackTrace();
                callback.onCallback(false);
            } finally {
                try {
                    fileOutputStream.flush();
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }.start();

}

From source file:com.jefftharris.passwdsafe.lib.view.ProgressFragment.java

@Override
public @NonNull Dialog onCreateDialog(Bundle savedInstanceState) {
    setCancelable(false);//from  ww  w .j av a2  s  .  c  om
    ProgressDialog dlg = new ProgressDialog(getActivity());
    dlg.setIndeterminate(true);
    dlg.setMessage(getArguments().getString("msg"));
    return dlg;
}