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:de.frank_durr.ble_v_monitor.MainActivity.java

/**
 * Query the GATT server for a voltage history.
 *
 * @param historyType the history to be retrieved from the GATT server
 *//* w  w w .j  a  va 2 s.c  om*/
synchronized private void bleRetrieveHistory(HistoryTypes historyType) {
    switch (historyType) {
    case historyMinutely:
        if (activeBluetoothTask != BluetoothTasks.getMinutelyHistory) {
            return;
        }
        break;
    case historyHourly:
        if (activeBluetoothTask != BluetoothTasks.getHourlyHistory) {
            return;
        }
        break;
    case historyDaily:
        if (activeBluetoothTask != BluetoothTasks.getDailyHistory) {
            return;
        }
        break;
    }

    // Check whether a BLE device has already been selected. If not, select device first.
    if (bluetoothDevice == null) {
        // No device selected so far -> let user select device now
        selectDevice();
        return; // Wait for activity result
    }

    // BLE device has been selected.

    if (!bluetoothAdapter.isEnabled()) {
        // First, turn on Bluetooth
        Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(intent, REQUEST_ENABLE_BT);
        return; // Wait for activity result
    }

    // BLE device has been selected. BLE is turned on.

    // From here on, we show a progress dialog ... retrieving hundreds of
    // BLE indications (stop&wait protocol) can take longer.
    if (progressDialog == null) {
        String dialogTitle = getString(R.string.waiting);
        String dialogMessage = getString(R.string.download_in_progress);
        String cancel = getString(R.string.cancel);
        progressDialog = new ProgressDialog(this);
        progressDialog.setTitle(dialogTitle);
        progressDialog.setMessage(dialogMessage);
        progressDialog.setCancelable(true);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setMax(MAX_HISTORY_SIZE);
        progressDialog.setProgress(0);
        progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, cancel,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finishTask();
                    }
                });
        progressDialog.show();
    }

    if (gatt == null) {
        bluetoothDevice.connectGatt(this, false, gattHandler);
        return; // Wait for callback
    }

    // BLE device has been selected. BLE is turned on. We are connected to GATT server.

    if (!gattServicesDiscovered) {
        if (!gatt.discoverServices()) {
            // Cannot start discovery
            toast(R.string.err_bluetooth_discovery);
            finishTask();
            return;
        }
        return; // Wait for GATT callback
    }

    // BLE device has been selected. BLE is turned on. We are connected to GATT server.
    // GATT services have been discovered.

    gattService = gatt.getService(gattServiceUUID);
    if (gattService == null) {
        // Required service not offered by device
        toast(R.string.err_bluetooth_service);
        finishTask();
        return;
    }

    // BLE device has been selected. BLE is turned on. We are connected to GATT server.
    // GATT services have been discovered. Service is ready.

    switch (historyType) {
    case historyMinutely:
        characteristic = gattService.getCharacteristic(minutelyHistoryCharacteristicUUID);
        break;
    case historyHourly:
        characteristic = gattService.getCharacteristic(hourlyHistoryCharacteristicUUID);
        break;
    case historyDaily:
        characteristic = gattService.getCharacteristic(dailyHistoryCharacteristicUUID);
        break;
    }

    if (characteristic == null) {
        // Required characteristic is not available.
        toast(R.string.err_bluetooth_characteristic);
        finishTask();
        return;
    }

    // BLE device has been selected. BLE is turned on. We are connected to GATT server.
    // GATT services have been discovered. Service is ready. Characteristic is available.

    // History values are returned as indications. -> subscribe for notifications.
    if (!gatt.setCharacteristicNotification(characteristic, true)) {
        toast(R.string.err_bluetooth_notification);
        finishTask();
        return;
    }
    BluetoothGattDescriptor descriptor = characteristic.getDescriptor(clientCharacteristicConfigurationUUID);
    if (descriptor == null) {
        toast(R.string.err_bluetooth_notification);
        finishTask();
        return;
    }
    if (!descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE)) {
        toast(R.string.err_bluetooth_notification);
        finishTask();
        return;
    }
    if (!gatt.writeDescriptor(descriptor)) {
        toast(R.string.err_bluetooth_notification);
        finishTask();
        return;
    }

    // Data is received and processed in GATT callback. Wait for GATT callback.
}

From source file:com.mci.firstidol.activity.MainActivity.java

private void doNewVersionUpdate(final String verName, String verCode, String newVerName, String newVerCode,
        String vCont, final String url) {
    StringBuffer sb = new StringBuffer();
    sb.append("?:");
    sb.append(verName);//  w  w w .j  a  v a 2s. c  o  m
    sb.append(" Code:");
    sb.append(verCode);
    sb.append(", ?:");
    sb.append(newVerName);
    sb.append(" Code:");
    sb.append(newVerCode);
    sb.append(", ??");
    sb.append(":");
    sb.append(vCont);
    Dialog dialog = new AlertDialog.Builder(MainActivity.this).setIcon(R.drawable.icon).setTitle("")
            .setMessage(sb.toString())
            // 
            .setPositiveButton("", // 
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            pBar = new ProgressDialog(MainActivity.this);
                            pBar.setTitle("");
                            pBar.setMessage("?...");
                            pBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                            //downFile(url);
                            setVersion(url, "Easy Idol", verName);
                        }

                    })
            .setNegativeButton("?", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    // "?"??
                    //finish();
                }
            }).create();// 
    // ?
    dialog.show();
}

From source file:id.ridon.keude.AppDetailsData.java

private ProgressDialog getProgressDialog(String file) {
    if (progressDialog == null) {
        final ProgressDialog pd = new ProgressDialog(this);
        pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        pd.setMessage(getString(R.string.download_server) + ":\n " + file);
        pd.setCancelable(true);//from   w w w . j a  v  a 2  s.co m
        pd.setCanceledOnTouchOutside(false);

        // The indeterminate-ness will get overridden on the first progress event we receive.
        pd.setIndeterminate(true);

        pd.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                Log.d(TAG, "User clicked 'cancel' on download, attempting to interrupt download thread.");
                if (downloadHandler != null) {
                    downloadHandler.cancel();
                    cleanUpFinishedDownload();
                } else {
                    Log.e(TAG, "Tried to cancel, but the downloadHandler doesn't exist.");
                }
                progressDialog = null;
                Toast.makeText(AppDetails.this, getString(R.string.download_cancelled), Toast.LENGTH_LONG)
                        .show();
            }
        });
        pd.setButton(DialogInterface.BUTTON_NEUTRAL, getString(R.string.cancel),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        pd.cancel();
                    }
                });
        progressDialog = pd;
    }
    return progressDialog;
}

From source file:br.liveo.ndrawer.ui.activity.MainActivity.java

License:asdf

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void startDevice() {
    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setTitle("? ?   ...");
    mProgressDialog.setMessage("");
    mProgressDialog.setMax(100);//from  w w w. j a  va2 s. c o  m
    mProgressDialog.setProgress(0);
    mProgressDialog.show();

    /*
    mlblMessage.setText("??   .");
    mBtnStart.setEnabled(false);
    mBtnStart.setVisibility(View.INVISIBLE);
    */

    // GATT database
    Resources res = getResources();
    XmlResourceParser xpp = res.getXml(R.xml.gatt_uuid);
    new GattInfo(xpp);

    if (!mReceiving) {
        registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
        mReceiving = true;
    }

    if (mGatt != null) {
        if (mGatt.getServices().size() == 0)
            discoverServices();
        else {
        }
    }
}

From source file:ro.ciubex.keepscreenlock.MainApplication.java

/**
 * This will show a progress dialog using a context and the message to be
 * showed on the progress dialog.//from w  w  w . j av a 2s . c om
 *
 * @param listener The listener class which should listen for cancel.
 * @param context  The context where should be displayed the progress dialog.
 * @param message  The message displayed inside of progress dialog.
 */
public void showProgressDialog(final ProgressCancelListener listener, Context context, String message,
        int max) {
    hideProgressDialog();
    mProgressDialog = new ProgressDialog(context);
    mProgressDialog.setTitle(R.string.please_wait);
    mProgressDialog.setMessage(message);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
            getApplicationContext().getString(R.string.cancel), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (listener != null) {
                        listener.onProgressCancel();
                    }
                }
            });
    if (max > 0) {
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setMax(max);
    }
    if (!mProgressDialog.isShowing()) {
        mProgressDialog.show();
    }
}

From source file:com.sssemil.sonyirremote.ir.ir.java

public void update() {
    final GetLastVer getLastVer1 = new GetLastVer(ir.this);
    try {/*from ww  w. jav  a  2s.c  o m*/
        Log.i("Update", "last_ver : " + getLastVer1.execute().get() + " cur_ver : " + cur_ver);
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
    if (last_ver == "zirt") {
        AlertDialog.Builder adb = new AlertDialog.Builder(this);
        adb.setTitle(getString(R.string.update));
        adb.setMessage(getString(R.string.ser3));
        adb.setIcon(android.R.drawable.ic_dialog_alert);
        adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                update();
            }
        });

        adb.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                //finish();
            }
        });
        adb.show();
    } else {
        String result = compare(cur_ver, last_ver);
        boolean doUpdate = false;
        if (result == ">") {
            doUpdate = false;
        } else if (result == "<") {
            doUpdate = true;
        } else if (result == "==") {
            doUpdate = false;
        }

        if (doUpdate == true) {
            AlertDialog.Builder adb = new AlertDialog.Builder(this);
            adb.setTitle(getString(R.string.update));
            adb.setMessage(getString(R.string.new_version_available));
            adb.setIcon(android.R.drawable.ic_dialog_alert);
            adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    mProgressDialog = new ProgressDialog(ir.this);
                    mProgressDialog.setMessage(getString(R.string.downloading_new));
                    mProgressDialog.setIndeterminate(true);
                    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                    mProgressDialog.setCancelable(true);

                    final DownloadApp downloadApp1 = new DownloadApp(ir.this);
                    downloadApp1.execute(http_path_last_download1 + last_ver + http_path_last_download2);

                    mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {
                            downloadApp1.cancel(true);
                        }
                    });
                }
            });

            adb.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            adb.show();
        } else if (doUpdate == false) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(getString(R.string.update));
            builder.setMessage(getString(R.string.already_new));
            builder.setPositiveButton("OK", null);
            builder.show();
        }
    }
}

From source file:org.mortbay.ijetty.IJetty.java

License:asdf

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case __SETUP_PROGRESS_DIALOG: {
        progressDialog = new ProgressDialog(IJetty.this);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setMessage("Finishing initial install ...");

        return progressDialog;
    }/*ww w.  jav a2  s .com*/
    default:
        return null;
    }
}

From source file:cgeo.geocaching.cgeocaches.java

private void refreshStored(final List<Geocache> caches, final int storeListId) {
    detailProgress = 0;/* ww  w  .jav  a  2 s .c  o  m*/

    showProgress(false);

    int etaTime = ((detailTotal * 25) / 60);
    String message;
    if (etaTime < 1) {
        message = res.getString(R.string.caches_downloading) + " " + res.getString(R.string.caches_eta_ltm);
    } else {
        message = res.getString(R.string.caches_downloading) + " " + etaTime + " "
                + res.getQuantityString(R.plurals.caches_eta_mins, etaTime);
    }

    progress.show(this, null, message, ProgressDialog.STYLE_HORIZONTAL,
            loadDetailsHandler.obtainMessage(MSG_CANCEL));
    progress.setMaxProgressAndReset(detailTotal);

    detailProgressTime = System.currentTimeMillis();

    threadDetails = new LoadDetailsThread(loadDetailsHandler, caches, storeListId);
    threadDetails.start();
}

From source file:net.phase.wallet.Currency.java

public Thread updateWalletBalance(Wallet w, boolean fast, int maxlength) {
    BalanceRetriever br = new BalanceRetriever(progressHandler, w, fast, maxlength);

    dialog = new ProgressDialog(this);
    dialog.setMessage("Obtaining balance (" + w.name + ")...");
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    if (fast)/*w  ww.  j  a v  a  2s .c  o  m*/
        dialog.setMax(w.getActiveKeyCount());
    else
        dialog.setMax(w.keys.length);
    dialog.setProgress(0);
    dialog.show();

    Thread t = new Thread(br);
    t.start();

    return t;
}