Example usage for android.app ProgressDialog setCancelable

List of usage examples for android.app ProgressDialog setCancelable

Introduction

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

Prototype

public void setCancelable(boolean flag) 

Source Link

Document

Sets whether this dialog is cancelable with the KeyEvent#KEYCODE_BACK BACK key.

Usage

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  . j  a v  a  2s  .co m*/
    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.nbplus.progress.ProgressDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final ProgressDialog dialog = new ProgressDialog(getActivity());

    dialog.setCancelable(false);
    this.setCancelable(false);

    // Disable the back button
    DialogInterface.OnKeyListener keyListener = new DialogInterface.OnKeyListener() {

        @Override//  w  w w . j  av a  2s  .  c o  m
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {

            if (keyCode == KeyEvent.KEYCODE_BACK) {
                return true;
            }
            return false;
        }

    };
    dialog.setOnKeyListener(keyListener);
    return dialog;
}

From source file:com.douncoding.noe.ui.component.ProgressDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setMessage(getArguments().getString(KEY_TITLE));
    dialog.setIndeterminate(true);// w ww . ja  v a2 s .c om
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    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");
    }/*from  www  .  j a v  a2 s.co  m*/
    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:org.retroshare.android.ConnectingToServiceFragmentDialog.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setMessage(getString(R.string.connecting_to_rsproxy));
    dialog.setIndeterminate(true);/*  w ww .  j  a v a  2  s. c om*/
    dialog.setCancelable(false);
    return dialog;
}

From source file:ztc1997.gxmu.teachingassessment.ui.ResetPwdActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_reset_pwd);

    password = (EditText) findViewById(R.id.password);
    check = (EditText) findViewById(R.id.check);
    btnResetPwd = (Button) findViewById(R.id.btn_reset_pwd);
    btnResetPwd.setOnClickListener(view -> {
        String pwd = password.getText().toString();
        String pwd2 = check.getText().toString();
        if (!pwd.equals(pwd2)) {
            check.setError(getString(R.string.error_reset_pwd_not_equals));
            return;
        }/*from   ww  w .  j  av a 2  s .com*/

        if (pwd.length() < 4) {
            password.setError(getString(R.string.error_reset_pwd_too_short));
            return;
        }
        ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.setCancelable(false);
        progressDialog.setMessage(getString(R.string.msg_reseting_pwd));
        progressDialog.show();

        new AlertDialog.Builder(this).setPositiveButton(android.R.string.ok, ((dialog, which) -> {
            Map<String, String> params = new HashMap<>();
            params.put("roleNum", BaseApplication.getStudentLoginInfo().getRoleNum());
            params.put("studentId", BaseApplication.getStudentLoginInfo().getStudentId());
            params.put("newPwd", pwd);
            StringRequest request = new StringRequest(Request.Method.POST,
                    PostUtils.mergeUrlActionParams("doResetPwdMobile", params), response -> {
                        try {
                            JSONObject jsonObject = new JSONArray(response).getJSONObject(0);
                            if ("ok".equals(jsonObject.getString("res"))) {
                                Toast.makeText(ResetPwdActivity.this, R.string.msg_reset_pwd_sucess,
                                        Toast.LENGTH_SHORT).show();
                                finish();
                                return;
                            }
                            password.setError(getString(R.string.error_reset_pwd_failed));
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }, e -> {
                        CrashReport.postCatchedException(e);
                        progressDialog.dismiss();
                        Toast.makeText(this, R.string.error_network_timeout, Toast.LENGTH_SHORT).show();
                    });
            request.setTag(TAG);
            BaseApplication.getRequestQueue().add(request);
        })).setNegativeButton(android.R.string.cancel, null).setTitle(R.string.title_dialog_reset_pwd)
                .setMessage(R.string.msg_dialog_reset_pwd).show();

    });
}

From source file:com.akalizakeza.apps.ishusho.activity.ProgressDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ProgressDialog dialog = new ProgressDialog(getActivity(), getTheme());
    dialog.setMessage(getArguments().getString(KEY_TITLE));
    dialog.setIndeterminate(true);//from w w  w .java2 s. c o  m
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}

From source file:org.deviceconnect.android.deviceplugin.linking.setting.fragment.dialog.DiscoveryDeviceDialogFragment.java

@NonNull
@Override/*from ww  w.  ja v a2s.  c  o  m*/
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    String message = getArguments().getString(EXTRA_MESSAGE);
    ProgressDialog progressDialog = new ProgressDialog(getActivity());
    progressDialog.setMessage(message);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setCancelable(false);
    return progressDialog;
}

From source file:fr.eoit.activity.LocationPricesActivity.java

@Override
protected void onResume() {
    super.onResume();

    if (!pricesUpdated) {
        ProgressDialog waitDialog = new ProgressDialog(this);
        waitDialog.setCancelable(true);
        waitDialog.setMessage(getString(R.string.retreiving_station_prices));
        waitDialog.show();/*w  w  w . j  ava2 s.c  om*/

        new UpdateFavoriteStationPriceAsyncTask(waitDialog, itemId).execute(this);
        pricesUpdated = true;
    }
}

From source file:uk.org.rivernile.edinburghbustracker.android.fragments.dialogs.IndeterminateProgressDialogFragment.java

/**
 * {@inheritDoc}//from  w ww  .  j  a v a 2  s.c  om
 */
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final ProgressDialog d = new ProgressDialog(getActivity());
    d.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    d.setCancelable(true);
    d.setMessage(getArguments().getString(ARG_MESSAGE));

    return d;
}