Example usage for android.app ProgressDialog setProgressStyle

List of usage examples for android.app ProgressDialog setProgressStyle

Introduction

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

Prototype

public void setProgressStyle(int style) 

Source Link

Document

Sets the style of this ProgressDialog, either #STYLE_SPINNER or #STYLE_HORIZONTAL .

Usage

From source file:com.qddagu.app.meetreader.ui.MainActivity.java

/**
 * ?//from ww w . j av  a 2 s. c om
 * @param handler
 */
public void loadMeeting(final String url) {
    final ProgressDialog mLoadingDialog = new ProgressDialog(this);
    mLoadingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mLoadingDialog.setTitle("??");
    mLoadingDialog.setMessage("??...");
    mLoadingDialog.setCancelable(false);
    mLoadingDialog.show();
    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            mLoadingDialog.dismiss();
            if (msg.what == 1) { //?
                Meeting meeting = ((Meeting) msg.obj);
                User user = meeting.getUser();
                if (user != null) {
                    //??
                    appContext.saveUserInfo(user);
                }
                appContext.setMeeting(meeting);//?
                appContext.saveHistory(meeting);//??

                UIHelper.showMeeting(MainActivity.this);
            } else if (msg.what == 0) { //
                UIHelper.ToastMessage(MainActivity.this, "");
            } else if (msg.what == -1 && msg.obj != null) {
                ((AppException) msg.obj).makeToast(MainActivity.this);
            }
        }
    };
    new Thread() {
        public void run() {
            Message msg = new Message();
            try {
                Meeting meeting = appContext.getMeeting(url);
                msg.what = (meeting != null && meeting.getId() > 0) ? 1 : 0;
                msg.obj = meeting;
            } catch (AppException e) {
                e.printStackTrace();
                msg.what = -1;
                msg.obj = e;
            }
            handler.sendMessage(msg);
        }
    }.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);// w w  w . jav  a2  s  .  com
    dialog.setMessage(message);
    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:com.softminds.matrixcalculator.OperationFragments.InverseFragment.java

@Override
public void onListItemClick(ListView L, View V, int position, long id) {
    ProgressDialog progressDialog = new ProgressDialog(getContext());
    progressDialog.setMessage(getString(R.string.Calculating));
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setIndeterminate(false);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.show();//from   w  w w .j ava  2 s .  c  o m
    progress = progressDialog;

    if (SquareList.get(position).getJamaMatrix().det() != 0) {
        if (ENABLED_NO_DECIMAL)
            RunAndGetDeterminantWithAdjoint(position, progressDialog);
        else
            RunNewGetInverse(position, progressDialog);
    } else {
        new AlertDialog.Builder(getContext())
                .setMessage("The Determinant of the matrix was Zero and Hence its Inverse does not exist")
                .setTitle("No Inverse Exist")
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).show();
        progressDialog.dismiss();
    }

}

From source file:net.zionsoft.obadiah.ui.fragments.ProgressDialogFragment.java

@Override
@NonNull/*from   www .j a  v  a2  s. c o m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final ProgressDialog dialog = new ProgressDialog(getActivity());

    final Bundle args = getArguments();
    if (args.containsKey(KEY_MAX_PROGRESS)) {
        dialog.setIndeterminate(false);
        dialog.setMax(args.getInt(KEY_MAX_PROGRESS));
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    }
    dialog.setMessage(getString(args.getInt(KEY_MESSAGE)));

    dialog.show();
    return dialog;
}

From source file:net.kazzz.NFCTagReader.java

public void onClick(final View v) {
    try {/*w w  w.  j a v a 2  s .  co m*/
        final int id = v.getId();

        final ProgressDialog dialog = new ProgressDialog(this);
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        dialog.setIndeterminate(true);

        AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() {
            @Override
            protected void onPreExecute() {
                switch (id) {
                case R.id.btn_read:
                    dialog.setMessage("?????...");
                    break;
                case R.id.btn_write:
                    dialog.setMessage("???????...");
                    break;
                case R.id.btn_hitory:
                    dialog.setMessage("????...");
                    break;
                }
                dialog.show();
            }

            @Override
            protected String doInBackground(Void... arg0) {
                switch (id) {
                case R.id.btn_read:
                    try {
                        return mLastFragment.dumpTagData();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                case R.id.btn_write:
                    try {
                        Intent intent = new Intent(NFCTagReader.this, NFCTagWriter.class);
                        intent.putExtra("nfcTag", mLastFragment.getNfcTag());
                        startActivity(intent);
                        return "";
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                case R.id.btn_hitory:
                    try {
                        if (mLastFragment != null && mLastFragment instanceof NfcFeliCaTagFragment) {
                            NfcFeliCaTagFragment nfcf = (NfcFeliCaTagFragment) mLastFragment;
                            return nfcf.dumpFeliCaHistoryData();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                default:
                    break;
                }
                return "";
            }

            /* (non-Javadoc)
             * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
             */
            @Override
            protected void onPostExecute(String result) {
                dialog.dismiss();
                TextView tv_tag = (TextView) findViewById(R.id.result_tv);
                if (result != null && result.length() > 0)
                    tv_tag.setText(result);
            }
        };

        task.execute();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.fabernovel.alertevoirie.HomeActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_PROGRESS:
        ProgressDialog pd = new ProgressDialog(this);
        pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        pd.setIndeterminate(true);//from  w  w  w . j a  va  2 s  . co m
        pd.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                if (dialog_shown)
                    removeDialog(DIALOG_PROGRESS);
            }
        });
        pd.setOnCancelListener(new OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                AVService.getInstance(HomeActivity.this).cancelTask();
                finish();
            }
        });
        pd.setMessage(getString(R.string.ui_message_loading));
        return pd;

    default:
        return super.onCreateDialog(id);
    }
}

From source file:com.esri.arcgisruntime.sample.exporttiles.MainActivity.java

/**
 * Show progress UI elements.//from w  w  w .ja v  a2 s  .com
 *
 * @param exportTileCacheJob used to track progress and cancel when required
 */
private void createProgressDialog(ExportTileCacheJob exportTileCacheJob) {

    ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setTitle("Export Tile Cache Job");
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel",
            (dialogInterface, i) -> exportTileCacheJob.cancel());
    progressDialog.show();

    exportTileCacheJob
            .addProgressChangedListener(() -> progressDialog.setProgress(exportTileCacheJob.getProgress()));
    exportTileCacheJob.addJobDoneListener(progressDialog::dismiss);
}

From source file:jp.co.noxi.app.NXProgressDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        final ProgressDialog dialog = mProgressDialog = new ProgressDialog(getActivity());
        dialog.setProgressStyle(mStyle);
        dialog.setIndeterminate(mIndeterminate);
        if (mMax > 0) {
            dialog.setMax(mMax);//from   w  w  w.java 2 s .c  o  m
        }
        if (mProgressVal > 0) {
            dialog.setProgress(mProgressVal);
        }
        if (mSecondaryProgressVal > 0) {
            dialog.setSecondaryProgress(mSecondaryProgressVal);
        }
        if (mMessage != null) {
            dialog.setMessage(mMessage);
        }
        if (mFormat != null) {
            dialog.setProgressNumberFormat(mFormat);
        }
        return dialog;
    } else {
        final ProgressDialogGB dialog = mProgressDialogGB = new ProgressDialogGB(getActivity());
        dialog.setProgressStyle(mStyle);
        dialog.setIndeterminate(mIndeterminate);
        if (mMax > 0) {
            dialog.setMax(mMax);
        }
        if (mProgressVal > 0) {
            dialog.setProgress(mProgressVal);
        }
        if (mSecondaryProgressVal > 0) {
            dialog.setSecondaryProgress(mSecondaryProgressVal);
        }
        if (mMessage != null) {
            dialog.setMessage(mMessage);
        }
        if (mFormat != null) {
            dialog.setProgressNumberFormat(mFormat);
        }
        return dialog;
    }
}

From source file:de.gebatzens.sia.SetupActivity.java

public void startDownloadingSchool() {
    final ProgressDialog d = new ProgressDialog(this);
    d.setTitle(SIAApp.SIA_APP.school.name);
    d.setMessage(getString(R.string.downloading_image));
    d.setCancelable(false);/*from   ww  w  .j a va 2 s  .c om*/
    d.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    d.show();

    new Thread() {
        @Override
        public void run() {
            if (!School.downloadImage(SIAApp.SIA_APP.school.image)) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Snackbar.make(getWindow().getDecorView().findViewById(R.id.coordinator_layout),
                                getString(R.string.download_error), Snackbar.LENGTH_LONG).show();
                    }
                });
            }

            //workaround for a bug that causes an endless loading screen
            Subst.GGPlans subst = SIAApp.SIA_APP.api.getPlans(false);
            subst.save();
            SIAApp.SIA_APP.school.fragments.getByType(FragmentData.FragmentType.PLAN).get(0).setData(subst);

            if (d.isShowing())
                d.dismiss();
            Intent i = new Intent(SetupActivity.this, MainActivity.class);
            //i.putExtra("reload", true);
            startActivity(i);
            finish();

        }
    }.start();
}

From source file:com.fabernovel.alertevoirie.NewsActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_PROGRESS:
        ProgressDialog pd = new ProgressDialog(this);
        pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        pd.setIndeterminate(true);//from  w  ww .j  a va2 s  .  c  om
        pd.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                removeDialog(DIALOG_PROGRESS);
            }
        });

        pd.setOnCancelListener(new OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                AVService.getInstance(NewsActivity.this).cancelTask();
                finish();
            }
        });

        pd.setMessage(getString(R.string.ui_message_loading));
        return pd;

    default:
        return super.onCreateDialog(id);
    }
}