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:org.alfresco.mobile.android.ui.operation.OperationWaitingDialogFragment.java

public Dialog onCreateDialog(final Bundle savedInstanceState) {
    if (getArguments() != null) {
        operationType = getArguments().getInt(ARGUMENT_TYPEID);
        intentId = getArguments().getString(ARGUMENT_INTENTID);
        iconId = getArguments().getInt(ARGUMENT_ICONID);
        title = getArguments().getString(ARGUMENT_TITLEID);
        message = getArguments().getString(ARGUMENT_MESSAGEID);
        parent = getArguments().getParcelable(ARGUMENT_NODEID);
        nbItems = getArguments().getInt(ARGUMENT_SIZE);
        operationId = getArguments().getString(ARGUMENT_OPERATIONID);
    }/*from   w  ww .j  a  v  a 2s  .co m*/

    ProgressDialog dialog = new ProgressDialog(getActivity());
    if (iconId == 0) {
        iconId = R.drawable.ic_application_logo;
    }
    dialog.setIcon(iconId);
    dialog.setTitle(title);
    if (message == null) {
        message = getString(R.string.waiting_operations);
    }
    dialog.setMessage(message);
    boolean indeterminate = true;
    if (nbItems > 0) {
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dialog.setProgress(0);
        dialog.setMax(nbItems);
        indeterminate = false;
    } else {
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    }
    dialog.setIndeterminate(indeterminate);
    dialog.setCancelable(false);
    dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (operationId != null) {
                        Operator.with(getActivity()).cancel(operationId);
                    }
                    dialog.dismiss();
                }
            });

    getActivity().getLoaderManager().restartLoader(this.hashCode(), null, this);

    return dialog;
}

From source file:net.pictulog.otgdb.MainActivityFragment.java

@Override
public void onBackupStart() {
    btnBackup.setEnabled(false);//from w w  w  .j av a  2  s.c  o m
    Log.d("MainActivityFragment", "Backing up " + files.size() + " files...");
    progressDialog = new ProgressDialog(getContext());
    progressDialog.setCancelable(false);
    progressDialog.setMessage(getText(R.string.backingUp));
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setProgress(0);
    progressDialog.setMax(files.size());
    progressDialog.show();
}

From source file:com.github.wakhub.monodict.activity.settings.DownloadsActivity.java

void startDownload(DownloadsItem downloadsItem) {
    progressDialog = new ProgressDialog(this);
    progressDialog.setTitle(R.string.message_in_processing);
    progressDialog.setIndeterminate(true);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setCancelable(false);

    dlTask.execute(downloadsItem.getUrl());
}

From source file:com.almunt.jgcaap.systemupdater.MainActivity.java

public void InitiateDownloadDialog(int position) {
    progressDialog = new ProgressDialog(MainActivity.this);
    progressDialog.setTitle("Downloading " + files.get(position).filename);
    progressDialog.setMessage("Downloading...");
    progressDialog.setCancelable(true);/*from w  w w  . j  ava2  s  . c om*/
    progressDialog.setIndeterminate(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
            File temp = new File(Environment.getExternalStorageDirectory() + "/JgcaapUpdates/temp/nd");
            try {
                temp.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
            progressDialog.dismiss();
            Toast.makeText(MainActivity.this, "Download Canceled", Toast.LENGTH_LONG).show();
        }
    });
    progressDialog.show();
    intent = new Intent(MainActivity.this, DownloadService.class);
    intent.putExtra("url", files.get(position).filename);
    intent.putExtra("receiver", new DownloadReceiver(new Handler()));
    intent.putExtra("stop", true);
    startService(intent);
}

From source file:org.sufficientlysecure.keychain.ui.EncryptMessageFragment.java

private void encryptStart(final boolean toClipboard) {
    // Send all information needed to service to edit key in other thread
    Intent intent = new Intent(getActivity(), KeychainIntentService.class);

    intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN);

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

    data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES);

    String message = mMessage.getText().toString();

    if (mEncryptInterface.isModeSymmetric()) {
        Log.d(Constants.TAG, "Symmetric encryption enabled!");
        String passphrase = mEncryptInterface.getPassphrase();
        if (passphrase.length() == 0) {
            passphrase = null;// w  w w . j  a va 2  s.co m
        }
        data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase);
    } else {
        data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey());
        data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS,
                mEncryptInterface.getEncryptionKeys());

        boolean signOnly = (mEncryptInterface.getEncryptionKeys() == null
                || mEncryptInterface.getEncryptionKeys().length == 0);
        if (signOnly) {
            message = fixBadCharactersForGmail(message);
        }
    }

    data.putByteArray(KeychainIntentService.ENCRYPT_MESSAGE_BYTES, message.getBytes());

    data.putBoolean(KeychainIntentService.ENCRYPT_USE_ASCII_ARMOR, true);

    int compressionId = Preferences.getPreferences(getActivity()).getDefaultMessageCompression();
    data.putInt(KeychainIntentService.ENCRYPT_COMPRESSION_ID, compressionId);

    intent.putExtra(KeychainIntentService.EXTRA_DATA, data);

    // Message is received after encrypting is done in KeychainIntentService
    KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(getActivity(),
            getString(R.string.progress_encrypting), ProgressDialog.STYLE_HORIZONTAL) {
        public void handleMessage(Message message) {
            // handle messages by standard KeychainIntentServiceHandler first
            super.handleMessage(message);

            if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
                // get returned data bundle
                Bundle data = message.getData();

                String output = new String(data.getByteArray(KeychainIntentService.RESULT_BYTES));
                Log.d(Constants.TAG, "output: " + output);

                if (toClipboard) {
                    ClipboardReflection.copyToClipboard(getActivity(), output);
                    AppMsg.makeText(getActivity(), R.string.encrypt_sign_clipboard_successful,
                            AppMsg.STYLE_INFO).show();
                } else {
                    Intent sendIntent = new Intent(Intent.ACTION_SEND);

                    // Type is set to text/plain so that encrypted messages can
                    // be sent with Whatsapp, Hangouts, SMS etc...
                    sendIntent.setType("text/plain");

                    sendIntent.putExtra(Intent.EXTRA_TEXT, output);
                    startActivity(Intent.createChooser(sendIntent, getString(R.string.title_share_with)));
                }
            }
        }
    };

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

    // show progress dialog
    saveHandler.showProgressDialog(getActivity());

    // start service with intent
    getActivity().startService(intent);
}

From source file:org.thialfihar.android.apg.ui.EncryptMessageFragment.java

private void encryptStart(final boolean toClipboard) {
    // Send all information needed to service to edit key in other thread
    Intent intent = new Intent(getActivity(), ApgIntentService.class);

    intent.setAction(ApgIntentService.ACTION_ENCRYPT_SIGN);

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

    data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);

    String message = mMessage.getText().toString();

    if (mEncryptInterface.isModeSymmetric()) {
        Log.d(Constants.TAG, "Symmetric encryption enabled!");
        String passphrase = mEncryptInterface.getPassphrase();
        if (passphrase.length() == 0) {
            passphrase = null;/*from w w w  .  j a  v  a2  s .c  o  m*/
        }
        data.putString(ApgIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase);
    } else {
        data.putLong(ApgIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey());
        data.putLongArray(ApgIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys());

        boolean signOnly = (mEncryptInterface.getEncryptionKeys() == null
                || mEncryptInterface.getEncryptionKeys().length == 0);
        if (signOnly) {
            message = fixBadCharactersForGmail(message);
        }
    }

    data.putByteArray(ApgIntentService.ENCRYPT_MESSAGE_BYTES, message.getBytes());

    data.putBoolean(ApgIntentService.ENCRYPT_USE_ASCII_ARMOR, true);

    int compressionId = Preferences.getPreferences(getActivity()).getDefaultMessageCompression();
    data.putInt(ApgIntentService.ENCRYPT_COMPRESSION_ID, compressionId);

    intent.putExtra(ApgIntentService.EXTRA_DATA, data);

    final Activity activity = getActivity();
    // Message is received after encrypting is done in ApgIntentService
    ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(getActivity(),
            getString(R.string.progress_encrypting), ProgressDialog.STYLE_HORIZONTAL) {
        public void handleMessage(Message message) {
            // handle messages by standard ApgIntentServiceHandler first
            super.handleMessage(message);

            if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
                // get returned data bundle
                Bundle data = message.getData();

                String output = new String(data.getByteArray(ApgIntentService.RESULT_BYTES));
                Log.d(Constants.TAG, "output: " + output);

                if (mLegacyMode) {
                    Intent result = new Intent();
                    result.putExtra("encryptedMessage", output);
                    activity.setResult(activity.RESULT_OK, result);
                    activity.finish();
                    return;
                } else if (toClipboard) {
                    ClipboardReflection.copyToClipboard(getActivity(), output);
                    AppMsg.makeText(getActivity(), R.string.encrypt_sign_clipboard_successful,
                            AppMsg.STYLE_INFO).show();
                } else {
                    Intent sendIntent = new Intent(Intent.ACTION_SEND);

                    // Type is set to text/plain so that encrypted messages can
                    // be sent with Whatsapp, Hangouts, SMS etc...
                    sendIntent.setType("text/plain");

                    sendIntent.putExtra(Intent.EXTRA_TEXT, output);
                    startActivity(Intent.createChooser(sendIntent, getString(R.string.title_share_with)));
                }
            }
        }
    };

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

    // show progress dialog
    saveHandler.showProgressDialog(getActivity());

    // start service with intent
    getActivity().startService(intent);
}

From source file:com.gmail.nagamatu.radiko.installer.RadikoInstallerActivity.java

private Dialog onCreateProgressDialog() {
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setMessage("Loading...");
    dialog.setCancelable(false);/*from   ww w.j  ava  2  s  . co  m*/
    return dialog;
}

From source file:nmtysh.android.test.speedtest.SpeedTestActivity.java

private void runHttpURLConnection() {
    final String url = urlEdit.getText().toString();
    if (url == null || (!url.startsWith("http://") && !url.startsWith("https://"))) {
        list.add("URL error!");
        adapter.notifyDataSetChanged();/*www  . j  av  a2 s.  com*/
        return;
    }
    task = new AsyncTask<Void, Integer, Void>() {
        long startTime;
        ProgressDialog progress;

        // ??
        @Override
        protected void onPreExecute() {
            super.onPreExecute();

            progress = new ProgressDialog(SpeedTestActivity.this);
            progress.setMessage(getString(R.string.progress_message));
            progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progress.setIndeterminate(false);
            progress.setCancelable(true);
            progress.setOnCancelListener(new OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    task.cancel(true);
                }
            });
            progress.setMax(10);
            progress.setProgress(0);
            progress.show();

            startTime = System.currentTimeMillis();
        }

        // ???
        @Override
        protected Void doInBackground(Void... params) {
            // 10?????
            for (int i = 0; i < 10; i++) {
                HttpURLConnection connection = null;
                InputStreamReader in = null;
                // BufferedReader br = null;
                try {
                    connection = (HttpURLConnection) (new URL(url)).openConnection();
                    connection.setRequestMethod("GET");
                    connection.connect();
                    in = new InputStreamReader(connection.getInputStream());
                    // br = new BufferedReader(in);
                    // while (br.readLine() != null) {
                    long len = 0;
                    while (in.read() != -1) {
                        len++;
                    }
                    Log.i("HttpURLConnection", len + " Bytes");
                } catch (IOException e) {
                } finally {
                    /*
                     * if (br != null) { try { br.close(); } catch
                     * (IOException e) { } br = null; }
                     */
                    if (in != null) {
                        try {
                            in.close();
                        } catch (IOException e) {
                        }
                        in = null;
                    }
                    if (connection != null) {
                        connection.disconnect();
                        connection = null;
                    }
                }
                publishProgress(i + 1);
                // Dos????????
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                }
            }
            return null;
        }

        @Override
        protected void onProgressUpdate(Integer... values) {
            super.onProgressUpdate(values);
            if (progress == null) {
                return;
            }
            progress.setProgress(values[0]);
        }

        // 
        @Override
        protected void onPostExecute(Void result) {
            long endTime = System.currentTimeMillis();

            // 
            progress.cancel();
            progress = null;

            list.add("HttpURLConnection:" + url + " " + (endTime - startTime) + "msec/10" + " "
                    + (endTime - startTime) / 10 + "msec");
            adapter.notifyDataSetChanged();
        }

        @Override
        protected void onCancelled() {
            super.onCancelled();
            progress.dismiss();
            progress = null;
        }
    }.execute();
}

From source file:org.exoplatform.utils.CompatibleFileOpen.java

private Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_DOWNLOAD_PROGRESS: // we set this to 0
        mProgressDialog = new DownloadProgressDialog(mContext);
        mProgressDialog.setMessage(downLoadingFile);
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setCancelable(true);
        mProgressDialog.show();// www . j  av  a 2s  .  c o m
        return mProgressDialog;
    default:
        return null;
    }
}

From source file:org.thialfihar.android.apg.ui.EditKeyActivity.java

/**
 * Handle intent action to create new key
 *
 * @param intent/*from  w  ww  .  j av a 2s . c o m*/
 */
private void handleActionCreateKey(Intent intent) {
    Bundle extras = intent.getExtras();

    mCurrentPassphrase = "";
    mIsBrandNewKeyring = true;

    if (extras != null) {
        // if userId is given, prefill the fields
        if (extras.containsKey(EXTRA_USER_IDS)) {
            Log.d(Constants.TAG, "UserIds are given!");
            mUserIds.add(extras.getString(EXTRA_USER_IDS));
        }

        // if no passphrase is given
        if (extras.containsKey(EXTRA_NO_PASSPHRASE)) {
            boolean noPassphrase = extras.getBoolean(EXTRA_NO_PASSPHRASE);
            if (noPassphrase) {
                // check "no passphrase" checkbox and remove button
                mNoPassphrase.setChecked(true);
                mChangePassphrase.setVisibility(View.GONE);
            }
        }

        // generate key
        if (extras.containsKey(EXTRA_GENERATE_DEFAULT_KEYS)) {
            boolean generateDefaultKeys = extras.getBoolean(EXTRA_GENERATE_DEFAULT_KEYS);
            if (generateDefaultKeys) {

                // Send all information needed to service generate keys in other thread
                final Intent serviceIntent = new Intent(this, ApgIntentService.class);
                serviceIntent.setAction(ApgIntentService.ACTION_GENERATE_DEFAULT_RSA_KEYS);

                // fill values for this action
                Bundle data = new Bundle();
                data.putString(ApgIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, mCurrentPassphrase);

                serviceIntent.putExtra(ApgIntentService.EXTRA_DATA, data);

                // Message is received after generating is done in ApgIntentService
                ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(this,
                        getResources().getQuantityString(R.plurals.progress_generating, 1),
                        ProgressDialog.STYLE_HORIZONTAL, true,

                        new DialogInterface.OnCancelListener() {
                            @Override
                            public void onCancel(DialogInterface dialog) {
                                // Stop key generation on cancel
                                stopService(serviceIntent);
                                EditKeyActivity.this.setResult(Activity.RESULT_CANCELED);
                                EditKeyActivity.this.finish();
                            }
                        }) {

                    @Override
                    public void handleMessage(Message message) {
                        // handle messages by standard ApgIntentServiceHandler first
                        super.handleMessage(message);

                        if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
                            // get new key from data bundle returned from service
                            Bundle data = message.getData();

                            ArrayList<PGPSecretKey> newKeys = PgpConversionHelper.BytesToPGPSecretKeyList(
                                    data.getByteArray(ApgIntentService.RESULT_NEW_KEY));

                            ArrayList<Integer> keyUsageFlags = data
                                    .getIntegerArrayList(ApgIntentService.RESULT_KEY_USAGES);

                            if (newKeys.size() == keyUsageFlags.size()) {
                                for (int i = 0; i < newKeys.size(); ++i) {
                                    mKeys.add(newKeys.get(i));
                                    mKeysUsages.add(keyUsageFlags.get(i));
                                }
                            }

                            buildLayout(true);
                        }
                    }
                };

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

                saveHandler.showProgressDialog(this);

                // start service with intent
                startService(serviceIntent);
            }
        }
    } else {
        buildLayout(false);
    }
}