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:com.esri.arcgisruntime.sample.exporttiles.MainActivity.java

/**
 * Show progress UI elements.// ww  w .jav a2 s  . com
 *
 * @param exportTileCacheJob used to track progress and cancel when required
 */
private void createProgressDialog(ExportTileCacheJob exportTileCacheJob) {

    ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setTitle("Export Tile Cache Job");
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel",
            (dialogInterface, i) -> exportTileCacheJob.cancel());
    progressDialog.show();

    exportTileCacheJob
            .addProgressChangedListener(() -> progressDialog.setProgress(exportTileCacheJob.getProgress()));
    exportTileCacheJob.addJobDoneListener(progressDialog::dismiss);
}

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

/**
 * Handle intent action to create new key
 *
 * @param intent// w w w  . ja v  a 2 s.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, KeychainIntentService.class);
                serviceIntent.setAction(KeychainIntentService.ACTION_GENERATE_DEFAULT_RSA_KEYS);

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

                serviceIntent.putExtra(KeychainIntentService.EXTRA_DATA, data);

                // Message is received after generating is done in KeychainIntentService
                KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(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 KeychainIntentServiceHandler first
                        super.handleMessage(message);

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

                            ArrayList<UncachedSecretKey> newKeys = PgpConversionHelper.BytesToPGPSecretKeyList(
                                    data.getByteArray(KeychainIntentService.RESULT_NEW_KEY));

                            ArrayList<Integer> keyUsageFlags = data
                                    .getIntegerArrayList(KeychainIntentService.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(KeychainIntentService.EXTRA_MESSENGER, messenger);

                saveHandler.showProgressDialog(this);

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

From source file:cn.org.cfpamf.data.base.BaseActivity.java

protected ProgressDialog createProgressDialog(String title, String message) {
    // ?????//from  ww w  .ja v  a 2s  .  com
    if (progressDialog == null) {
        progressDialog = new ProgressDialog(this);
    }
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);// ?
    progressDialog.setCancelable(true);// ??Back?
    progressDialog.setCanceledOnTouchOutside(false);// Dialog??Dialog?
    progressDialog.setTitle(title);
    progressDialog.setMessage(message);
    if (!progressDialog.isShowing())
        progressDialog.show();
    return progressDialog;
}

From source file:com.googlecode.networklog.ExportDialog.java

public FutureTask showProgressDialog(final Context context) {
    FutureTask futureTask = new FutureTask(new Runnable() {
        public void run() {
            progressDialog = new ProgressDialog(context);
            progressDialog.setIndeterminate(false);
            progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progressDialog.setMax(progress_max);
            progressDialog.setCancelable(false);
            progressDialog.setTitle("");
            progressDialog.setMessage(context.getResources().getString(R.string.exporting_log));

            progressDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
                    context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            canceled = true;
                        }/*from   w ww .  j av  a2s  .  com*/
                    });

            progressDialog.show();
            progressDialog.setProgress(progress);
        }
    }, null);

    NetworkLog.handler.post(futureTask);
    return futureTask;
}

From source file:com.simadanesh.isatis.LoginActivity.java

@Override
public void pleaseWait() {
    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setMessage(getResources().getString(R.string.info_connecting_server));
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setCancelable(false);
    mProgressDialog.show();//from w ww.  ja v a  2s .  c  o  m

}

From source file:de.sauernetworks.stm32_bluetooth_flashloader.BluetoothUpdaterFragment.java

private void createDialog(int id) {
    switch (id) {
    case DIALOG_CONNECT_PROGRESS:
        mProgressDialog = new ProgressDialog(this.getActivity());
        mProgressDialog.setMessage("Connecting..");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setCancelable(false);
        if (!mProgressDialog.isShowing())
            mProgressDialog.show();/*from  w  w  w .  java2s  .c o m*/
        break;
    case DIALOG_ERASE_PROGRESS:
        mProgressDialog = new ProgressDialog(this.getActivity());
        mProgressDialog.setMessage("Erasing Memory..");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setCancelable(false);
        if (!mProgressDialog.isShowing())
            mProgressDialog.show();
        break;
    case DIALOG_DOWNLOAD_PROGRESS:
        mProgressDialog = new ProgressDialog(this.getActivity());
        mProgressDialog.setMessage("Downloading memory..\n(1/"
                + String.valueOf((STM32_PAGE_COUNT * STM32_BYTE_COUNT) / 1024) + " kb)");
        mProgressDialog.setMax(STM32_PAGE_COUNT);
        mProgressDialog.setProgressNumberFormat("%1d of %2d Pages read");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setCancelable(false);
        if (!mProgressDialog.isShowing())
            mProgressDialog.show();
        break;
    case DIALOG_UPLOAD_PROGRESS:
        mProgressDialog = new ProgressDialog(this.getActivity());
        /*if (firmware_upload_size > 1024)
            mProgressDialog.setMessage("Uploading memory..\n(1/"+String.valueOf(firmware_upload_size / 1024)+" kb)");
        else*/
        mProgressDialog
                .setMessage("Uploading memory..\n(1/" + String.valueOf(firmware_upload_size) + " bytes)");
        if ((firmware_upload_size / 256) <= 1)
            mProgressDialog.setMax(1);
        else
            mProgressDialog.setMax((int) (firmware_upload_size / STM32_BYTE_COUNT));
        mProgressDialog.setProgressNumberFormat("%1d of %2d Pages written");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setCancelable(false);
        if (!mProgressDialog.isShowing())
            mProgressDialog.show();
        break;
    case DIALOG_START_BOOTLOADER_INFO:
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(R.string.dialog_start_bootloader_info_message)
                .setPositiveButton(R.string.dialog_start_bootloader_info_button_start,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                final Handler handler = new Handler();
                                handler.postDelayed(new Runnable() {
                                    @Override
                                    public void run() {
                                        try {
                                            mBootloader.init();
                                        } catch (IOException e) {
                                            Toast.makeText(getActivity(), R.string.toast_error_command_running,
                                                    Toast.LENGTH_SHORT).show();
                                            e.printStackTrace();
                                        }
                                    }
                                }, 500);
                            }
                        })
                .setNegativeButton(R.string.dialog_start_bootloader_info_button_cancel,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                // User cancelled the dialog
                            }
                        })
                .show();
        break;
    }
}

From source file:com.tlongdev.bktf.ui.fragment.RecentsFragment.java

@Override
public void updateLoadingDialog(int max, String message) {
    if (loadingDialog != null && loadingDialog.isShowing()) {
        if (loadingDialog.isIndeterminate()) {
            loadingDialog.dismiss();/* ww w.  j  av a2s  .c  om*/
            loadingDialog = new ProgressDialog(mContext);
            loadingDialog.setIndeterminate(false);
            loadingDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            loadingDialog.setMessage(message);
            loadingDialog.setMax(max);
            loadingDialog.setCancelable(false);
            loadingDialog.show();
        } else {
            loadingDialog.incrementProgressBy(1);
        }
    }
}

From source file:com.mobicage.rogerthat.plugins.messaging.AttachmentViewerActivity.java

@Override
protected void onServiceBound() {
    T.UI();// w w  w.j av  a2s. co m

    mProgressDialog = new ProgressDialog(AttachmentViewerActivity.this);
    mProgressDialog.setMessage(mService.getString(R.string.downloading));
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setCancelable(true);

    mMessagingPlugin = mService.getPlugin(MessagingPlugin.class);

    final Intent intent = getIntent();
    mThreadKey = intent.getStringExtra("thread_key");
    mMessageKey = intent.getStringExtra("message");
    mContentType = intent.getStringExtra("content_type");
    mDownloadUrl = intent.getStringExtra("download_url");
    mName = intent.getStringExtra("name");
    mDownloadUrlHash = intent.getStringExtra("download_url_hash");
    mGenerateThumbnail = intent.getBooleanExtra("generate_thumbnail", false);

    if (mContentType.toLowerCase(Locale.US).startsWith("video/")) {
        setContentView(R.layout.file_viewer_video);
        mVideoview = (VideoView) findViewById(R.id.videoView);
    } else {
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        setContentView(R.layout.file_viewer);
        mWebview = (WebView) findViewById(R.id.webview);

        mWebview.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onConsoleMessage(String message, int lineNumber, String sourceID) {
                if (sourceID != null) {
                    try {
                        sourceID = new File(sourceID).getName();
                    } catch (Exception e) {
                        L.d("Could not get fileName of sourceID: " + sourceID, e);
                    }
                }
                L.d(sourceID + ":" + lineNumber + " | " + message);
            }
        });

        mWebview.setWebViewClient(new WebViewClient() {

            @Override
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                L.d(failingUrl + ":" + errorCode + " | " + description);
            }
        });

        final TextView titleTextView = (TextView) findViewById(R.id.title);
        if (TextUtils.isEmptyOrWhitespace(mName)) {
            titleTextView.setVisibility(View.GONE);
            findViewById(R.id.divider).setVisibility(View.GONE);
        } else {
            titleTextView.setVisibility(View.VISIBLE);
            titleTextView.setText(mName);
            findViewById(R.id.divider).setVisibility(View.VISIBLE);
        }
    }

    try {
        mAttachmentsDir = mMessagingPlugin.attachmentsDir(mThreadKey, null);
    } catch (IOException e) {
        L.d("Unable to create attachment directory", e);
        UIUtils.showAlertDialog(this, "", R.string.unable_to_read_write_sd_card);
        return;
    }

    mFile = new File(mAttachmentsDir, mDownloadUrlHash);

    if (mMessagingPlugin.attachmentExists(mAttachmentsDir, mDownloadUrlHash)) {
        updateView(false);
    } else {
        try {
            mAttachmentsDir = mMessagingPlugin.attachmentsDir(mThreadKey, mMessageKey);
        } catch (IOException e) {
            L.d("Unable to create attachment directory", e);
            UIUtils.showAlertDialog(this, "", R.string.unable_to_read_write_sd_card);
            return;
        }

        mFile = new File(mAttachmentsDir, mDownloadUrlHash);

        if (mMessagingPlugin.attachmentExists(mAttachmentsDir, mDownloadUrlHash)) {
            updateView(false);
        } else {
            downloadAttachment();
        }
    }
}

From source file:jieehd.villain.updater.VillainUpdater.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_DOWNLOAD_PROGRESS:
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setMessage("Downloading File...");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setCancelable(true);
        mProgressDialog.setProgress(0);/*from ww  w . j av a  2s .c  om*/
        mProgressDialog.show();
        return mProgressDialog;
    default:
        return null;
    }
}

From source file:org.totschnig.myexpenses.activity.ManageCategories.java

private void importCats() {
    getSupportFragmentManager().beginTransaction()
            .add(TaskExecutionFragment.newInstanceGrisbiImport(false, null, true, false),
                    ProtectionDelegate.ASYNC_TAG)
            .add(ProgressDialogFragment.newInstance(0, 0, ProgressDialog.STYLE_HORIZONTAL, false),
                    ProtectionDelegate.PROGRESS_TAG)
            .commit();//  ww  w  . j  a  va2  s  .c  o m

}