Example usage for android.app ProgressDialog STYLE_HORIZONTAL

List of usage examples for android.app ProgressDialog STYLE_HORIZONTAL

Introduction

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

Prototype

int STYLE_HORIZONTAL

To view the source code for android.app ProgressDialog STYLE_HORIZONTAL.

Click Source Link

Document

Creates a ProgressDialog with a horizontal progress bar.

Usage

From source file:it.scoppelletti.mobilepower.app.ProgressDialogFragment.java

/**
 * Crea il dialogo./*from w  w w.j  av  a 2s.com*/
 * 
 * @param  savedInstanceState Stato dell’istanza.
 * @return                    Dialogo.
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int max, resId;
    ProgressDialog dlg;
    Bundle args = getArguments();

    dlg = new ProgressDialog(getActivity(), AppUtils.getDialogTheme());

    resId = args.getInt(ProgressDialogFragment.ARG_TITLEID);
    dlg.setTitle(getString(resId));
    max = args.getInt(ProgressDialogFragment.ARG_MAX, -1);

    if (max > 0) {
        dlg.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dlg.setIndeterminate(false);
        dlg.setMax(max);
    } else {
        dlg.setIndeterminate(true);
        dlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    }

    dlg.setCancelable(args.getBoolean(ProgressDialogFragment.ARG_CANCELABLE));
    dlg.setCanceledOnTouchOutside(false);

    return dlg;
}

From source file:org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment.java

/**
 * Creates dialog// w  ww  .  j a  va  2s . co m
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();

    final String deleteFile = getArguments().getString(ARG_DELETE_FILE);

    AlertDialog.Builder alert = new AlertDialog.Builder(activity);

    alert.setIcon(android.R.drawable.ic_dialog_alert);
    alert.setTitle(R.string.warning);
    alert.setMessage(this.getString(R.string.fileDeleteConfirmation, deleteFile));

    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();

            // Send all information needed to service to edit key in other thread
            Intent intent = new Intent(activity, KeychainIntentService.class);

            // fill values for this action
            Bundle data = new Bundle();

            intent.putExtra(KeychainIntentService.EXTRA_ACTION,
                    KeychainIntentService.ACTION_DELETE_FILE_SECURELY);
            data.putString(KeychainIntentService.DELETE_FILE, deleteFile);
            intent.putExtra(KeychainIntentService.EXTRA_DATA, data);

            ProgressDialogFragment deletingDialog = ProgressDialogFragment
                    .newInstance(R.string.progress_deletingSecurely, ProgressDialog.STYLE_HORIZONTAL);

            // Message is received after deleting is done in ApgService
            KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(activity,
                    deletingDialog) {
                public void handleMessage(Message message) {
                    // handle messages by standard ApgHandler first
                    super.handleMessage(message);

                    if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
                        Toast.makeText(activity, R.string.fileDeleteSuccessful, Toast.LENGTH_SHORT).show();
                    }
                };
            };

            // Create a new Messenger for the communication back
            Messenger messenger = new Messenger(saveHandler);
            intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);

            // show progress dialog
            deletingDialog.show(activity.getSupportFragmentManager(), "deletingDialog");

            // start service with intent
            activity.startService(intent);
        }
    });
    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dismiss();
        }
    });
    alert.setCancelable(true);

    return alert.create();
}

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

/**
 * Creates dialog/* w w  w . java 2  s. co m*/
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();

    final String deleteFile = getArguments().getString(ARG_DELETE_FILE);

    AlertDialog.Builder alert = new AlertDialog.Builder(activity);

    alert.setIcon(R.drawable.ic_dialog_alert_holo_light);
    alert.setTitle(R.string.warning);
    alert.setMessage(this.getString(R.string.file_delete_confirmation, deleteFile));

    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();

            // Send all information needed to service to edit key in other thread
            Intent intent = new Intent(activity, ApgIntentService.class);

            // fill values for this action
            Bundle data = new Bundle();

            intent.setAction(ApgIntentService.ACTION_DELETE_FILE_SECURELY);
            data.putString(ApgIntentService.DELETE_FILE, deleteFile);
            intent.putExtra(ApgIntentService.EXTRA_DATA, data);

            ProgressDialogFragment deletingDialog = ProgressDialogFragment.newInstance(
                    getString(R.string.progress_deleting_securely), ProgressDialog.STYLE_HORIZONTAL, false,
                    null);

            // Message is received after deleting is done in ApgService
            ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(activity, deletingDialog) {
                public void handleMessage(Message message) {
                    // handle messages by standard ApgHandler first
                    super.handleMessage(message);

                    if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
                        Toast.makeText(activity, R.string.file_delete_successful, Toast.LENGTH_SHORT).show();
                    }
                }
            };

            // Create a new Messenger for the communication back
            Messenger messenger = new Messenger(saveHandler);
            intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);

            // show progress dialog
            deletingDialog.show(activity.getSupportFragmentManager(), "deletingDialog");

            // start service with intent
            activity.startService(intent);
        }
    });
    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dismiss();
        }
    });
    alert.setCancelable(true);

    return alert.create();
}

From source file:com.softminds.matrixcalculator.OperationFragments.AdjointFragment.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  ww. j  av  a  2s .co  m*/
    RunToGetDeterminant(position, progressDialog);
}

From source file:com.yandex.disk.rest.example.UploadFileFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    dialog = new ProgressDialog(getActivity());
    dialog.setTitle(R.string.example_uploading_file_title);
    dialog.setMessage(localFile);//from   ww  w  .j ava2  s.  c om
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setIndeterminate(true);
    dialog.setButton(ProgressDialog.BUTTON_NEUTRAL, getString(R.string.example_loading_file_cancel_button),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    onCancel();
                }
            });
    dialog.setOnCancelListener(this);
    dialog.show();
    return dialog;
}

From source file:me.xingrz.finder.ZipFinderActivity.java

@Override
protected void onCreateInternal(Bundle savedInstanceState) {
    super.onCreateInternal(savedInstanceState);

    current = new File(getIntent().getData().getPath());

    try {//w  w  w .j  a  v  a 2  s.  com
        zipFile = new ZipFile(current);
        zipFile.setRunInThread(true);
    } catch (ZipException e) {
        Log.d(TAG, "failed to open zip file " + current.getAbsolutePath(), e);
    }

    if (getIntent().hasExtra(EXTRA_PREFIX)) {
        toolbar.setTitle(FilenameUtils.getName(getIntent().getStringExtra(EXTRA_PREFIX)));
        toolbar.setSubtitle(current.getName());
    }

    passwordPrompt = new AlertDialog.Builder(this).setView(R.layout.dialog_password)
            .setPositiveButton("", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    confirmFilePassword();
                }
            }).create();

    progressMonitor = zipFile.getProgressMonitor();

    progressDialog = new ProgressDialog(this);
    progressDialog.setMax(100);
    progressDialog.setCancelable(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
}

From source file:com.yandex.disk.rest.example.DeleteItemFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    dialog = new ProgressDialog(getActivity());
    dialog.setTitle(isCollection ? R.string.example_delete_folder_title : R.string.example_delete_file_title);
    dialog.setMessage(displayName);// w  w  w. j av a  2 s .  co m
    dialog.setIndeterminate(true);
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setButton(ProgressDialog.BUTTON_NEUTRAL, getText(R.string.example_make_folder_negative_button),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    onCancel();
                }
            });
    return dialog;
}

From source file:org.cvasilak.jboss.mobile.admin.net.UploadToJBossServerTask.java

@Override
protected void onPreExecute() {
    progressDialog = new ProgressDialog(context);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setMessage(context.getString(R.string.uploading));
    progressDialog.setCancelable(true);//from  ww  w. j  a va 2s.com
    progressDialog.show();
}

From source file:com.googlecode.android_scripting.ZipExtractorTask.java

@Override
protected void onPreExecute() {
    Log.v("Extracting " + mInput.getAbsolutePath() + " to " + mOutput.getAbsolutePath());
    if (mDialog != null) {
        mDialog.setTitle("Extracting");
        mDialog.setMessage(mInput.getName());
        mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mDialog.setOnCancelListener(new OnCancelListener() {
            @Override//from  www. j  a  v  a  2 s  . com
            public void onCancel(DialogInterface dialog) {
                cancel(true);
            }
        });
        mDialog.show();
    }
}

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

/**
 * Creates dialog//from  ww  w  .  ja v  a2  s . c  o m
 */
@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;
}