Example usage for android.app ProgressDialog setIndeterminate

List of usage examples for android.app ProgressDialog setIndeterminate

Introduction

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

Prototype

public void setIndeterminate(boolean indeterminate) 

Source Link

Document

Change the indeterminate mode for this ProgressDialog.

Usage

From source file:com.rastating.droidbeard.MainActivity.java

private void restartSickbeard(boolean prompt) {
    if (prompt) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Confirmation").setMessage("Are you sure you want to restart SickBeard?")
                .setCancelable(true).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    @Override//from w ww. jav  a2s. co m
                    public void onClick(DialogInterface dialogInterface, int i) {
                        restartSickbeard(false);
                    }
                }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).create().show();
    } else {
        final ProgressDialog dialog = new ProgressDialog(this);
        dialog.setTitle("Restarting");
        dialog.setMessage("Please wait...");
        dialog.setCancelable(false);
        dialog.setIndeterminate(true);
        dialog.show();

        RestartTask task = new RestartTask(this);
        task.addResponseListener(new ApiResponseListener<Boolean>() {
            @Override
            public void onApiRequestFinished(SickbeardAsyncTask sender, Boolean result) {
                dialog.dismiss();
            }
        });
        task.start();
    }
}

From source file:fm.smart.r1.CreateExampleActivity.java

public void onClick(View v) {
    EditText exampleInput = (EditText) findViewById(R.id.create_example_sentence);
    EditText translationInput = (EditText) findViewById(R.id.create_example_translation);
    EditText exampleTransliterationInput = (EditText) findViewById(R.id.sentence_transliteration);
    EditText translationTransliterationInput = (EditText) findViewById(R.id.translation_transliteration);
    final String example = exampleInput.getText().toString();
    final String translation = translationInput.getText().toString();
    if (TextUtils.isEmpty(example) || TextUtils.isEmpty(translation)) {
        Toast t = Toast.makeText(this, "Example and translation are required fields", 150);
        t.setGravity(Gravity.CENTER, 0, 0);
        t.show();/*from   w  ww.  j a v  a2  s .co m*/
    } else {
        final String example_language_code = Utils.LANGUAGE_MAP.get(example_language);
        final String translation_language_code = Utils.LANGUAGE_MAP.get(translation_language);
        final String example_transliteration = exampleTransliterationInput.getText().toString();
        final String translation_transliteration = translationTransliterationInput.getText().toString();

        if (LoginActivity.isNotLoggedIn(this)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setClassName(this, LoginActivity.class.getName());
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid
            // navigation
            // back to this?
            LoginActivity.return_to = CreateExampleActivity.class.getName();
            LoginActivity.params = new HashMap<String, String>();
            LoginActivity.params.put("goal_id", goal_id);
            LoginActivity.params.put("item_id", item_id);
            LoginActivity.params.put("example", example);
            LoginActivity.params.put("translation", translation);
            LoginActivity.params.put("example_language", example_language);
            LoginActivity.params.put("translation_language", translation_language);
            LoginActivity.params.put("example_transliteration", example_transliteration);
            LoginActivity.params.put("translation_transliteration", translation_transliteration);
            startActivity(intent);
        } else {

            final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
            myOtherProgressDialog.setTitle("Please Wait ...");
            myOtherProgressDialog.setMessage("Creating Example ...");
            myOtherProgressDialog.setIndeterminate(true);
            myOtherProgressDialog.setCancelable(true);

            final Thread create_example = new Thread() {
                public void run() {
                    // TODO make this interruptable .../*if
                    // (!this.isInterrupted())*/
                    try {
                        // TODO failures here could derail all ...
                        CreateExampleActivity.add_item_goal_result = new AddItemResult(
                                Main.lookup.addItemToGoal(Main.transport, goal_id, item_id, null));

                        Result result = null;
                        try {
                            result = Main.lookup.createExample(Main.transport, translation,
                                    translation_language_code, translation, null, null, null);
                            JSONObject json = new JSONObject(result.http_response);
                            String text = json.getString("text");
                            String translation_id = json.getString("id");
                            result = Main.lookup.createExample(Main.transport, example, example_language_code,
                                    example_transliteration, translation_id, item_id, goal_id);
                        } catch (UnsupportedEncodingException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        CreateExampleActivity.create_example_result = new CreateExampleResult(result);

                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    myOtherProgressDialog.dismiss();

                }
            };
            myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    create_example.interrupt();
                }
            });
            OnCancelListener ocl = new OnCancelListener() {
                public void onCancel(DialogInterface arg0) {
                    create_example.interrupt();
                }
            };
            myOtherProgressDialog.setOnCancelListener(ocl);
            myOtherProgressDialog.show();
            create_example.start();
        }
    }
}

From source file:com.ntsync.android.sync.activities.CreatePwdProgressDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setMessage(getText(R.string.keypwd_activity_createpwd));
    dialog.setIndeterminate(true);

    return dialog;
}

From source file:com.esri.arcgisruntime.generateofflinemap.MainActivity.java

/**
 * Use the generate offline map job to generate an offline map.
 *///from   w  w w  .  ja v  a  2  s . c om
private void generateOfflineMap() {

    // create a progress dialog to show download progress
    ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setTitle("Generate Offline Map Job");
    progressDialog.setMessage("Taking map offline...");
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setIndeterminate(false);
    progressDialog.setProgress(0);

    // when the button is clicked, start the offline map task job
    mTakeMapOfflineButton.setOnClickListener(v -> {
        progressDialog.show();

        // delete any offline map already in the cache
        String tempDirectoryPath = getCacheDir() + File.separator + "offlineMap";
        deleteDirectory(new File(tempDirectoryPath));

        // specify the extent, min scale, and max scale as parameters
        double minScale = mMapView.getMapScale();
        double maxScale = mMapView.getMap().getMaxScale();
        // minScale must always be larger than maxScale
        if (minScale <= maxScale) {
            minScale = maxScale + 1;
        }
        GenerateOfflineMapParameters generateOfflineMapParameters = new GenerateOfflineMapParameters(
                mDownloadArea.getGeometry(), minScale, maxScale);

        // create an offline map offlineMapTask with the map
        OfflineMapTask offlineMapTask = new OfflineMapTask(mMapView.getMap());

        // create an offline map job with the download directory path and parameters and start the job
        GenerateOfflineMapJob job = offlineMapTask.generateOfflineMap(generateOfflineMapParameters,
                tempDirectoryPath);

        // replace the current map with the result offline map when the job finishes
        job.addJobDoneListener(() -> {
            if (job.getStatus() == Job.Status.SUCCEEDED) {
                GenerateOfflineMapResult result = job.getResult();
                mMapView.setMap(result.getOfflineMap());
                mGraphicsOverlay.getGraphics().clear();
                mTakeMapOfflineButton.setEnabled(false);
                Toast.makeText(this, "Now displaying offline map.", Toast.LENGTH_LONG).show();
            } else {
                String error = "Error in generate offline map job: " + job.getError().getAdditionalMessage();
                Toast.makeText(this, error, Toast.LENGTH_LONG).show();
                Log.e(TAG, error);
            }
            progressDialog.dismiss();
        });

        // show the job's progress with the progress dialog
        job.addProgressChangedListener(() -> progressDialog.setProgress(job.getProgress()));

        // start the job
        job.start();
    });

}

From source file:com.ubuntuone.android.files.activity.StoreActivity.java

/**
 * Builds a simple indeterminate progress dialog.
 * //from   w ww  .j a v  a 2s. co m
 * @param messageResId
 *            the message resource id to use
 * @return a simple progress dialog
 */
private ProgressDialog buildSimpleProgressDialog(int messageResId) {
    final ProgressDialog dialog = new ProgressDialog(StoreActivity.this);
    dialog.setIcon(android.R.drawable.ic_dialog_info);
    dialog.setIndeterminate(true);
    dialog.setMessage(getText(messageResId));
    return dialog;
}

From source file:com.mobility.android.ui.vehicle.AddVehicleActivity.java

private void uploadPicture(File file) {
    ProgressDialog dialog = new ProgressDialog(this, R.style.DialogStyle);
    dialog.setMessage("Loading image...");
    dialog.setIndeterminate(true);
    dialog.setCancelable(false);/*from w  w w  . j av a2s  .com*/
    dialog.show();

    Glide.with(AddVehicleActivity.this).load(file).animate(android.R.anim.fade_in).into(imageBackground);

    base64(file).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<String>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    e.printStackTrace();
                    dialog.dismiss();

                    UIUtils.okDialog(AddVehicleActivity.this, "Error", "Couldn't load image.");
                }

                @Override
                public void onNext(String s) {
                    Timber.w("Loaded image base64, size: %s KB", s.length() / 1024);
                    vehicle.image = s;

                    dialog.dismiss();
                }
            });
}

From source file:com.quickcar.thuexe.UI.ListPassengerActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    GPSTracker gps = new GPSTracker(mContext);
    if (!gps.canGetLocation()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setTitle("Thng bo"); // GPS not found
        builder.setMessage(/*from w  w  w.j  av a 2 s. c  o  m*/
                "Chc nng ny cn ly v tr hin ti ca bn.Bn c mun bt nh v?"); // Want to enable?
        builder.setPositiveButton("Tip tc", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS),
                        1);
            }
        });
        builder.setNegativeButton("Khng", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        builder.create().show();
        return;
    }
    final ProgressDialog locate = new ProgressDialog(mContext);
    locate.setIndeterminate(true);
    locate.setCancelable(false);
    locate.setMessage("?ang ly v tr...");
    locate.show();
    if (gps.getLongitude() == 0 && gps.getLatitude() == 0) {
        gps.getLocationCoodinate(new GPSTracker.LocateListener() {
            @Override
            public void onLocate(double mlongitude, double mlatitude) {
                if (dataMap != null)
                    dataMap.OnDataMap();
                if (dataPasser != null)
                    dataPasser.onDataPass();
                locate.dismiss();
                //Toast.makeText(mContext, mlongitude+","+mlatitude,Toast.LENGTH_SHORT).show();
            }
        });
    } else {
        if (dataMap != null)
            dataMap.OnDataMap();
        if (dataPasser != null)
            dataPasser.onDataPass();
        //Toast.makeText(mContext, gps.getLongitude()+","+gps.getLatitude(),Toast.LENGTH_SHORT).show();
        locate.dismiss();
    }

}

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

/**
 * Crea il dialogo.//  w w  w  .  j a  v  a2  s.  co m
 * 
 * @param  savedInstanceState Stato dell&rsquo;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:com.mobility.android.ui.vehicle.AddVehicleActivity.java

private void uploadVehicle() {
    ProgressDialog dialog = new ProgressDialog(this, R.style.DialogStyle);
    dialog.setMessage("Adding vehicle...");
    dialog.setIndeterminate(true);
    dialog.setCancelable(false);//www  .j  a v  a 2s .co  m
    dialog.show();

    vehicle.lat = (float) place.getLatLng().latitude;
    vehicle.lng = (float) place.getLatLng().longitude;
    vehicle.address = place.getAddress().toString();
    vehicle.country = "IT";

    vehicle.name = name.getText().toString();
    vehicle.availability = availability.getText().toString();
    vehicle.licencePlate = isCar ? licencePlate.getText().toString() : null;
    vehicle.description = description.getText().toString();
    vehicle.pricePerHour = Float.parseFloat(price.getText().toString());
    vehicle.currency = "EUR";

    vehicle.type = isCar ? "car" : "bike";

    Timber.e("Uploading vehicle: %s", vehicle);

    VehicleApi api = RestClient.ADAPTER.create(VehicleApi.class);
    api.addVehicle(vehicle).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<VehicleObject>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    e.printStackTrace();
                    dialog.dismiss();
                    UIUtils.okDialog(AddVehicleActivity.this, "Error", "Couldn't add vehicle.");
                }

                @Override
                public void onNext(VehicleObject object) {
                    Timber.w("Added vehicle");
                    dialog.dismiss();

                    Intent intent = new Intent(AddVehicleActivity.this, VehicleDetailsActivity.class);
                    intent.putExtra(Config.EXTRA_VEHICLE, object);
                    startActivity(intent);
                    finish();
                }
            });
}

From source file:com.juick.android.UserCenterActivity.java

private void enableJAM(final Runnable then) {
    if (!MainActivity.isJAMServiceRunning(UserCenterActivity.this)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setCancelable(true);// w ww  .jav  a2s. co m
        builder.setMessage(R.string.JAMNotEnabledEnable);
        builder.setTitle(getString(R.string.JuickAdvancedFunctionality));
        builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(UserCenterActivity.this);
                sp.edit().putBoolean("enableJAMessaging", true).commit();
                MainActivity.toggleJAMessaging(UserCenterActivity.this, true);
                final ProgressDialog pd = new ProgressDialog(UserCenterActivity.this);
                dialog.cancel();
                pd.setIndeterminate(true);
                pd.setMessage(getString(R.string.WaitingForService));
                final Thread thread = new Thread() {
                    @Override
                    public void run() {
                        while (true) {
                            try {
                                JAMService instance = JAMService.instance;
                                if (instance != null) {
                                    JAXMPPClient client = instance.client;
                                    if (client != null && client.loggedIn) {
                                        runOnUiThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                pd.cancel();
                                                then.run();
                                            }
                                        });
                                    }
                                }
                                Thread.sleep(500);
                            } catch (InterruptedException e) {
                                break;
                            }
                        }
                        super.run(); //To change body of overridden methods use File | Settings | File Templates.
                    }
                };
                thread.start();
                pd.setCancelable(true);
                pd.setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        thread.interrupt();
                    }
                });
                pd.show();
            }
        });
        builder.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        builder.show();
    } else {
        then.run();
    }
    return;
}