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: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);/*from  ww w  .ja  v  a2  s.c o  m*/
    dialog.setCancelable(true);
    return dialog;
}

From source file:org.dash.wallet.integration.uphold.ui.UpholdAccountActivity.java

private void loadUserBalance() {
    final ProgressDialog loadingDialog = new ProgressDialog(this);
    loadingDialog.setIndeterminate(true);
    loadingDialog.setCancelable(false);
    loadingDialog.setMessage(getString(R.string.loading));
    loadingDialog.show();/*from  w  w  w  .  j  av  a 2 s . c om*/

    UpholdClient.getInstance().getDashBalance(new UpholdClient.Callback<BigDecimal>() {
        @Override
        public void onSuccess(BigDecimal data) {
            balance = data;
            balanceView.setAmount(Coin.parseCoin(balance.toString()));
            loadingDialog.cancel();
        }

        @Override
        public void onError(Exception e, boolean otpRequired) {
            loadingDialog.cancel();
            showErrorAlert();
        }
    });
}

From source file:org.thialfihar.android.apg.ui.dialog.ProgressDialogFragment.java

/**
 * Creates dialog/*ww  w.ja v  a 2  s.com*/
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();

    ProgressDialog dialog = new ProgressDialog(activity);
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);

    String message = getArguments().getString(ARG_MESSAGE);
    int style = getArguments().getInt(ARG_STYLE);
    boolean cancelable = getArguments().getBoolean(ARG_CANCELABLE);

    dialog.setMessage(message);
    dialog.setProgressStyle(style);

    if (cancelable) {
        dialog.setButton(DialogInterface.BUTTON_NEGATIVE, activity.getString(R.string.progress_cancel),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
    }

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

        @Override
        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:org.mobisocial.corral.BackgroundableDownloadDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ProgressDialog d = new ProgressDialog(getActivity());
    d.setTitle("Fetching file");
    d.setMessage("Preparing to download...");
    d.setIndeterminate(true);// w  ww.ja va  2s . c o  m
    d.setCancelable(true);
    d.setButton(DialogInterface.BUTTON_POSITIVE, "Background", mBackgroundListener);
    d.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", mCancelListener);
    return d;
}

From source file:com.lauszus.dronedraw.DroneDrawActivity.java

private void uploadFileToDropbox(File file) {
    DbxClientV2 client;//w ww .  j  a va2  s  .  c om
    try {
        client = DropboxClientFactory.getClient();
    } catch (IllegalStateException e) {
        Toast.makeText(DroneDrawActivity.this, "Please setup your Dropbox account", Toast.LENGTH_SHORT).show();
        return;
    }

    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    dialog.setCancelable(false);
    dialog.setMessage("Uploading to Dropbox");
    dialog.show();

    new UploadFileTask(client, new UploadFileTask.Callback() {
        @Override
        public void onUploadComplete(FileMetadata result) {
            dialog.dismiss();
            Toast.makeText(DroneDrawActivity.this, "Path uploaded to Dropbox", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onError(Exception e) {
            dialog.dismiss();
            if (D)
                Log.e(TAG, "Failed to upload file: ", e);
            Toast.makeText(DroneDrawActivity.this, "Failed to upload path to Dropbox", Toast.LENGTH_SHORT)
                    .show();
        }
    }).execute(Uri.fromFile(file).toString(), "");
}

From source file:com.jaanussiim.slimtimer.android.activities.LoginActivity.java

@Override
protected Dialog onCreateDialog(final int id) {
    switch (id) {
    case DIALOG_LOGGING_IN: {
        ProgressDialog dialog = new ProgressDialog(this);
        dialog.setMessage(getText(R.string.logging_in_message));
        dialog.setIndeterminate(true);/* w ww .  j  a v a  2s  . c  o  m*/
        dialog.setCancelable(true);
        dialog.setOnCancelListener(this);
        return dialog;
    }
    case DIALOG_AUTHENTICATION_ERROR:
    case DIALOG_NETWORK_ERROR:
    case DIALOG_UNKNOWN_ERROR:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.login_error_dialog_title);
        if (id == DIALOG_AUTHENTICATION_ERROR) {
            builder.setMessage(R.string.login_error_authentication_error);
        } else if (id == DIALOG_NETWORK_ERROR) {
            builder.setMessage(R.string.login_error_network_error);
        } else {
            builder.setMessage(R.string.login_error_network_error);
        }
        builder.setIcon(android.R.drawable.ic_dialog_alert);
        builder.setPositiveButton(R.string.button_title_ok, null);
        return builder.create();
    default:
        return super.onCreateDialog(id);
    }
}

From source file:net.evendanan.android.thumbremote.ui.FragmentAlertDialogSupport.java

private Dialog creatDiscoveryProgressDialog() {
    ProgressDialog p = new ProgressDialog(getActivity());
    p.setTitle(R.string.discoverying_dialog_title);
    p.setMessage(getString(R.string.discoverying_dialog_message));
    p.setIndeterminate(true);/*  w  w w .  j  av a2  s  .co m*/
    p.setCancelable(false);

    return p;
}

From source file:org.totschnig.myexpenses.dialog.ProgressDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final ProgressDialog dialog = new ProgressDialog(getActivity());
    int message = getArguments().getInt("message");
    if (message != 0)
        dialog.setMessage(getString(message));
    else//ww  w  . j  ava2s  . com
        dialog.setMessage("");
    dialog.setIndeterminate(true);
    dialog.setCancelable(false);

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

        @Override
        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.manning.androidhacks.hack023.authenticator.AuthenticatorActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage("Login in");
    dialog.setIndeterminate(true);/*  w w  w .j  a va2s .  c o m*/
    dialog.setCancelable(true);
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
            if (mAuthThread != null) {
                mAuthThread.interrupt();
                finish();
            }
        }
    });
    return dialog;
}

From source file:com.cuddlesoft.nori.APISettingsActivity.java

@Override
public void editService(final long rowId, final String name, final String url, final String username,
        final String passphrase) {
    // Show progress dialog during the service type detection process.
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setIndeterminate(true);/*from   ww w  . j ava  2 s . c o m*/
    dialog.setCancelable(false);
    dialog.setMessage(getString(R.string.dialog_message_detectingApiType));
    dialog.show();

    // Register broadcast receiver to get results from the background service type detection service.
    registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            // Get result code from received intent.
            int resultCode = intent.getIntExtra(ServiceTypeDetectionService.RESULT_CODE, -1);
            if (resultCode == ServiceTypeDetectionService.RESULT_OK) {
                // Add a new service to the database on a background thread.
                // This is so database I/O doesn't block the UI thread.
                SearchClient.Settings.APIType apiType = SearchClient.Settings.APIType.values()[intent
                        .getIntExtra(ServiceTypeDetectionService.API_TYPE, 0)];
                final SearchClient.Settings settings = new SearchClient.Settings(apiType, name, url, username,
                        passphrase);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        APISettingsDatabase database = new APISettingsDatabase(APISettingsActivity.this);
                        if (rowId == ROW_ID_INSERT) {
                            database.insert(settings);
                        } else {
                            database.update(rowId, settings);
                        }
                        database.close();
                    }
                }).run();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_INVALID_URL) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_serviceUriInvalid,
                        Toast.LENGTH_LONG).show();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_NETWORK) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_noNetwork, Toast.LENGTH_LONG)
                        .show();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_NO_API) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_noServiceAtGivenUri,
                        Toast.LENGTH_LONG).show();
            }

            // Unregister the broadcast receiver.
            unregisterReceiver(this);
            // Dismiss progress dialog.
            dialog.dismiss();
        }
    }, new IntentFilter(ServiceTypeDetectionService.ACTION_DONE));

    // Start the background service type detection service.
    Intent serviceIntent = new Intent(this, ServiceTypeDetectionService.class);
    serviceIntent.putExtra(ServiceTypeDetectionService.ENDPOINT_URL, url);
    startService(serviceIntent);
}