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.rastating.droidbeard.MainActivity.java

private void restartSickbeard(boolean prompt) {
    if (prompt) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Confirmation").setMessage("Are you sure you want to restart SickBeard?")
                .setCancelable(true).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    @Override/*from   w ww .jav  a2s . co m*/
                    public void onClick(DialogInterface dialogInterface, int i) {
                        restartSickbeard(false);
                    }
                }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).create().show();
    } else {
        final ProgressDialog dialog = new ProgressDialog(this);
        dialog.setTitle("Restarting");
        dialog.setMessage("Please wait...");
        dialog.setCancelable(false);
        dialog.setIndeterminate(true);
        dialog.show();

        RestartTask task = new RestartTask(this);
        task.addResponseListener(new ApiResponseListener<Boolean>() {
            @Override
            public void onApiRequestFinished(SickbeardAsyncTask sender, Boolean result) {
                dialog.dismiss();
            }
        });
        task.start();
    }
}

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

/**
 * ?/* w ww.  j  a v 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:org.xbmc.android.remote.presentation.controller.AbstractController.java

public void onWrongConnectionState(int state, final INotifiableManager manager, final Command<?> source) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    switch (state) {
    case WifiHelper.WIFI_STATE_DISABLED:
        builder.setTitle("Wifi disabled");
        builder.setMessage("This host is Wifi only. Should I activate Wifi?");
        builder.setNeutralButton("Activate Wifi", new OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                final ProgressDialog pd = new ProgressDialog(mActivity);
                pd.setCancelable(true);
                pd.setTitle("Activating Wifi");
                pd.setMessage("Please wait while Wifi is activated.");
                pd.show();//w  ww  .  j  ava 2  s .  c om
                (new Thread() {
                    public void run() {
                        final WifiHelper helper = WifiHelper.getInstance(mActivity);
                        helper.enableWifi(true);
                        int wait = 0;
                        while (wait <= MAX_WAIT_FOR_WIFI * 1000
                                && helper.getWifiState() != WifiHelper.WIFI_STATE_ENABLED) {
                            try {
                                sleep(500);
                                wait += 500;
                            } catch (InterruptedException e) {
                            }
                        }
                        manager.retryAll();
                        pd.cancel();
                        mDialogShowing = false;

                    }
                }).start();
            }
        });
        showDialog(builder);
        break;
    case WifiHelper.WIFI_STATE_ENABLED:
        final Host host = HostFactory.host;
        final WifiHelper helper = WifiHelper.getInstance(mActivity);
        final String msg;
        if (host != null && host.access_point != null && !host.access_point.equals("")) {
            helper.connect(host);
            msg = "Connecting to " + host.access_point + ". Please wait";
        } else {
            msg = "Waiting for Wifi to connect to your LAN.";
        }
        final ProgressDialog pd = new ProgressDialog(mActivity);
        pd.setCancelable(true);
        pd.setTitle("Connecting");
        pd.setMessage(msg);
        mWaitForWifi = new Thread() {
            public void run() {
                mDialogShowing = true;
                pd.show();
                (new Thread() {
                    public void run() {
                        int wait = 0;
                        while (wait <= MAX_WAIT_FOR_WIFI * 1000
                                && helper.getWifiState() != WifiHelper.WIFI_STATE_CONNECTED) {
                            try {
                                sleep(500);
                                wait += 500;
                            } catch (InterruptedException e) {
                            }
                        }
                        pd.cancel();
                        mDialogShowing = false;
                    }
                }).start();
                pd.setOnDismissListener(new OnDismissListener() {
                    public void onDismiss(DialogInterface dialog) {
                        if (helper.getWifiState() != WifiHelper.WIFI_STATE_CONNECTED) {
                            builder.setTitle("Wifi doesn't seem to connect");
                            builder.setMessage(
                                    "You can open the Wifi settings or wait " + MAX_WAIT_FOR_WIFI + " seconds");
                            builder.setNeutralButton("Wifi Settings", new OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    mDialogShowing = false;
                                    mActivity.startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));
                                }
                            });
                            builder.setCancelable(true);
                            builder.setNegativeButton("Wait", new OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    mDialogShowing = false;
                                    mActivity.runOnUiThread(mWaitForWifi); //had to make the Thread a field because of this line
                                }
                            });

                            mActivity.runOnUiThread(new Runnable() {
                                public void run() {
                                    final AlertDialog alert = builder.create();
                                    try {
                                        if (!mDialogShowing) {
                                            alert.show();
                                            mDialogShowing = true;
                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            });
                        }
                    }

                });
            }
        };
        mActivity.runOnUiThread(mWaitForWifi);
    }

}

From source file:com.almarsoft.GroundhogReader.ComposeActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    if (id == ID_DIALOG_POSTING) {
        ProgressDialog loadingDialog = new ProgressDialog(this);
        loadingDialog.setMessage(getString(R.string.posting_message));
        loadingDialog.setIndeterminate(true);
        loadingDialog.setCancelable(true);
        return loadingDialog;
    }//from   w  w  w  .  j  a  v  a  2  s  . c  o m

    return super.onCreateDialog(id);
}

From source file:com.progym.custom.fragments.FoodProgressDailyPieFragment.java

public void setPieData(final Date dateToSetUp, final boolean isLeftIn) {

    final ProgressDialog ringProgressDialog = ProgressDialog.show(getActivity(),
            getResources().getString(R.string.please_wait), getResources().getString(R.string.populating_data),
            true);/*from ww w  .  ja va  2s  .  c o m*/
    ringProgressDialog.setCancelable(true);
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                DATE = dateToSetUp;
                totalProtein = 0;
                totalFat = 0;
                totalCarbs = 0;
                totalCallories = 0;
                final String date = Utils.formatDate(DATE, DataBaseUtils.DATE_PATTERN_YYYY_MM_DD);
                List<Ingridient> ingridients = DataBaseUtils.getProductsOnPlate(date);
                if (null != ingridients) {

                    for (Ingridient ingridient : ingridients) {
                        totalProtein += ingridient.protein;
                        totalFat += ingridient.fat;
                        totalCarbs += ingridient.carbohydrates;
                        totalCallories += ingridient.kkal;
                        Utils.log(String.format(
                                "==========prot:%s == carbs:%s == name:%s == fat %s============",
                                ingridient.protein, ingridient.carbohydrates, ingridient.name, ingridient.fat));
                    }

                    getActivity().runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            twCurrentDay.setText(Utils.formatDate(dateToSetUp, "EEEE") + " - "
                                    + Utils.formatDate(dateToSetUp, "dd") + " of "
                                    + Utils.formatDate(dateToSetUp, "MMM"));

                        }
                    });

                    setUpPieChart(totalProtein, totalFat, totalCarbs, isLeftIn);

                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            ringProgressDialog.dismiss();
        }
    }).start();
}

From source file:com.android.messaging.ui.appsettings.ApnSettingsActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    if (id == DIALOG_RESTORE_DEFAULTAPN) {
        ProgressDialog dialog = new ProgressDialog(this);
        dialog.setMessage(getResources().getString(R.string.restore_default_apn));
        dialog.setCancelable(false);
        return dialog;
    }//from  w w w  . ja  v a  2  s  .  com
    return null;
}

From source file:com.ta.TAActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_ID_PROGRESS_DEFAULT:
        ProgressDialog dlg = new ProgressDialog(this);
        // dlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        dlg.setMessage("...");
        dlg.setCancelable(true);
        return dlg;
    default:/*from   ww w .jav  a 2 s  . c  o  m*/
        return super.onCreateDialog(id);

    }
}

From source file:com.pansapiens.occyd.Search.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_SEARCHING: {
        ProgressDialog dialog = new ProgressDialog(this);
        dialog.setTitle("Searching ...");
        dialog.setMessage("Searching ...");
        dialog.setIndeterminate(true);//from www  .j a v  a2 s .c  o m
        dialog.setCancelable(false);
        return dialog;
    }
    }
    return null;
}

From source file:org.protocoder.appApi.ProtoScripts.java

public void shareProtoFileDialog(String folder, String name) {
    final ProgressDialog progress = new ProgressDialog(mProtocoder.a);
    progress.setTitle("Exporting .proto");
    progress.setMessage("Your project will be ready soon!");
    progress.setCancelable(true);
    progress.setCanceledOnTouchOutside(false);
    progress.show();//  ww w. ja va 2s .c o  m

    String zipFilePath = exportProto(folder, name);

    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(zipFilePath)));
    shareIntent.setType("application/zip");

    progress.dismiss();

    mProtocoder.a.startActivity(
            Intent.createChooser(shareIntent, mProtocoder.a.getResources().getText(R.string.share_proto_file)));
}

From source file:com.ubuntuone.android.files.activity.StoreActivity.java

/**
 * Builds an "updating account info" dialog. It is not cancellable to avoid
 * user seeing old account info right after storage purchase.
 * //from   w  w w  .j  ava  2 s.  c  o m
 * @return a dialog indicating updating account info
 */
private Dialog buildUpdatingAccountInfoDialog() {
    final ProgressDialog dialog = buildSimpleProgressDialog(R.string.progress_updating_please_wait);
    dialog.setCancelable(false);
    return dialog;
}