Example usage for android.app ProgressDialog setTitle

List of usage examples for android.app ProgressDialog setTitle

Introduction

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

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

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);
    // ?//from w  w  w.j a  va  2s . c  o 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.mobicage.rogerthat.util.ui.UIUtils.java

public static ProgressDialog showProgressDialog(final Context context, CharSequence title, CharSequence message,
        boolean indeterminate, boolean cancelable, DialogInterface.OnCancelListener onCancelListener,
        int progressStyle, boolean show) {
    ProgressDialog dialog = new ProgressDialog(context);
    dialog.setTitle(title);
    dialog.setMessage(message);//from ww  w.j  a v  a 2  s  . co  m
    dialog.setIndeterminate(indeterminate);
    dialog.setCancelable(cancelable);
    dialog.setProgressNumberFormat(null);
    dialog.setProgressPercentFormat(null);
    dialog.setOnCancelListener(onCancelListener);
    dialog.setProgressStyle(progressStyle);
    dialog.setOnShowListener(new ProgressDialog.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            ProgressDialog progressDialog = (ProgressDialog) dialog;
            ProgressBar progressBar = (ProgressBar) progressDialog.findViewById(android.R.id.progress);
            UIUtils.setColors(context, progressBar);
        }
    });
    if (show) {
        dialog.show();
    }
    return dialog;
}

From source file:fr.enseirb.odroidx.remote_client.UI.ScanningDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setTitle("Scanning...");
    dialog.setIndeterminate(true);//ww w.  j  ava 2 s.c om
    return dialog;
}

From source file:com.booksaround.me.title.util.dialog.ProgressDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // get args/*from  w ww. jav  a 2s .  c  om*/
    Bundle args = getArguments();
    String title = args.getString(ARGS_TITLE);
    String msg = args.getString(ARGS_MESSAGE);

    ProgressDialog progress = new ProgressDialog(getActivity());
    progress.setTitle(title);
    progress.setMessage(msg);

    return progress;
}

From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Dialogs.MyProgressDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final android.app.ProgressDialog dialog = new android.app.ProgressDialog(getActivity());
    dialog.setTitle(getArguments().getString("title"));
    dialog.setMessage(getArguments().getString("message"));
    dialog.setIndeterminate(true);/*  www .  j a  v a 2 s .c o m*/
    dialog.setCancelable(true);
    return dialog;
}

From source file:cz.tomas.StockAnalyze.fragments.ProgressDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (getArguments() == null) {
        throw new RuntimeException("use newInstance(...) static method to initialize this dialog");
    }//www.  j a  va2  s .c  om
    int title = getArguments().getInt("title");
    int messageId = getArguments().getInt("message");

    ProgressDialog dlg = new ProgressDialog(getActivity());
    dlg.setTitle(title);
    dlg.setMessage(getText(messageId));
    dlg.setCancelable(true);
    dlg.setIndeterminate(true);
    return dlg;
}

From source file:com.kii.sample.hellothingif.util.ProgressDialogFragment.java

@NonNull
@Override//from w ww.java  2  s  .  co m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // get args
    Bundle args = getArguments();
    String title = args.getString(ARGS_TITLE);
    String msg = args.getString(ARGS_MESSAGE);

    ProgressDialog progress = new ProgressDialog(getActivity());
    progress.setTitle(title);
    progress.setMessage(msg);

    return progress;
}

From source file:org.openbmap.activities.ExportGpxTaskFragment.java

/**
 * Restores previously retained progress dialog state
 * @param progressDialog//from   w w  w .  j a v  a 2 s .  c  o  m
 */
public void restoreProgress(final ProgressDialog progressDialog) {
    progressDialog.setTitle(mTitle);
    progressDialog.setMessage(mMessage);
    progressDialog.setProgress(mProgress);
}

From source file:org.alfresco.mobile.android.ui.fragments.WaitingDialogFragment.java

public Dialog onCreateDialog(final Bundle savedInstanceState) {
    if (getArguments() != null) {
        titleId = getArguments().getInt(ARGUMENT_TITLEID);
        messageId = getArguments().getInt(ARGUMENT_MESSAGEID);
        isCancelable = getArguments().getBoolean(ARGUMENT_CANCELABLE);
    }/* w ww.  j  a v a 2  s  .  co  m*/

    final ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setTitle(titleId);
    dialog.setMessage(getString(messageId));
    dialog.setIndeterminate(true);
    dialog.setCancelable(isCancelable);
    return dialog;
}

From source file:com.github.yuukis.businessmap.app.ProgressDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    boolean cancelable = getArguments().getBoolean(CANCELABLE, false);
    setCancelable(cancelable);// w  ww  .  j ava2s . co m

    String title = getArguments().getString(TITLE);
    String message = getArguments().getString(MESSAGE);
    ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setIndeterminate(false);
    dialog.setCanceledOnTouchOutside(false);

    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setMax(getArguments().getInt(MAX));

    return dialog;
}