List of usage examples for android.app ProgressDialog dismiss
@Override public void dismiss()
From source file:de.bahnhoefe.deutschlands.bahnhofsfotos.DetailsActivity.java
private void uploadPhoto() { final ProgressDialog progress = new ProgressDialog(DetailsActivity.this); progress.setMessage(getResources().getString(R.string.send)); progress.setTitle(getResources().getString(R.string.app_name)); progress.setProgressStyle(ProgressDialog.STYLE_SPINNER); progress.show();//from w w w .j a va2 s . c om final File mediaFile = getStoredMediaFile(); RequestBody file = RequestBody .create(MediaType.parse(URLConnection.guessContentTypeFromName(mediaFile.getName())), mediaFile); rsapi.photoUpload(email, token, bahnhof.getId(), countryCode.toLowerCase(), file) .enqueue(new Callback<Void>() { @Override public void onResponse(Call<Void> call, Response<Void> response) { progress.dismiss(); switch (response.code()) { case 202: new SimpleDialogs().confirm(DetailsActivity.this, R.string.upload_completed); break; case 400: new SimpleDialogs().confirm(DetailsActivity.this, R.string.upload_bad_request); break; case 401: new SimpleDialogs().confirm(DetailsActivity.this, R.string.upload_token_invalid); break; case 409: new SimpleDialogs().confirm(DetailsActivity.this, R.string.upload_conflict); break; case 413: new SimpleDialogs().confirm(DetailsActivity.this, R.string.upload_too_big); break; default: new SimpleDialogs().confirm(DetailsActivity.this, String.format(getText(R.string.upload_failed).toString(), response.code())); } } @Override public void onFailure(Call<Void> call, Throwable t) { Log.e(TAG, "Error uploading photo", t); progress.dismiss(); new SimpleDialogs().confirm(DetailsActivity.this, String.format(getText(R.string.upload_failed).toString(), t.getMessage())); } }); }
From source file:com.easemob.chatuidemo.activity.main.MainActivity.java
void logout() { final ProgressDialog pd = new ProgressDialog(this); String st = getResources().getString(R.string.Are_logged_out); pd.setMessage(st);/*from w w w . j a v a 2 s . c o m*/ pd.setCanceledOnTouchOutside(false); pd.show(); DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() { @Override public void onSuccess() { runOnUiThread(new Runnable() { public void run() { pd.dismiss(); // ?? finish(); startActivity(new Intent(MainActivity.this, LoginActivity.class)); } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { runOnUiThread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub pd.dismiss(); Toast.makeText(MainActivity.this, "unbind devicetokens failed", Toast.LENGTH_SHORT).show(); } }); } }); }
From source file:com.mobicage.rogerthat.GetLocationActivity.java
@Override protected void onServiceBound() { T.UI();//ww w . ja va 2 s . c o m setContentView(R.layout.get_location); mProgressDialog = new ProgressDialog(this); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mProgressDialog.setMessage(getString(R.string.updating_location)); mProgressDialog.setCancelable(true); mProgressDialog.setCanceledOnTouchOutside(true); mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { T.UI(); if (mLocationManager != null) { try { mLocationManager.removeUpdates(mLocationListener); } catch (SecurityException e) { L.bug(e); // Should never happen } } } }); mProgressDialog.setMax(10000); mUseGPS = (CheckBox) findViewById(R.id.use_gps_provider); mGetCurrentLocationButton = (Button) findViewById(R.id.get_current_location); mAddress = (EditText) findViewById(R.id.address); mCalculate = (Button) findViewById(R.id.calculate); mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (mLocationManager == null) { mGetCurrentLocationButton.setEnabled(false); } else { mUseGPS.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked && !mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { new AlertDialog.Builder(GetLocationActivity.this).setMessage(R.string.gps_is_not_enabled) .setPositiveButton(R.string.yes, new SafeDialogInterfaceOnClickListener() { @Override public void safeOnClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(intent, TURNING_ON_GPS); } }).setNegativeButton(R.string.no, new SafeDialogInterfaceOnClickListener() { @Override public void safeOnClick(DialogInterface dialog, int which) { mUseGPS.setChecked(false); } }).create().show(); } } }); mGetCurrentLocationButton.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { T.UI(); if (mService.isPermitted(Manifest.permission.ACCESS_FINE_LOCATION)) { getMyLocation(); } else { ActivityCompat.requestPermissions(GetLocationActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, PERMISSION_REQUEST_ACCESS_FINE_LOCATION); } } }); } mCalculate.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { final ProgressDialog pd = new ProgressDialog(GetLocationActivity.this); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); pd.setMessage(getString(R.string.updating_location)); pd.setCancelable(false); pd.setIndeterminate(true); pd.show(); final String addressText = mAddress.getText().toString(); mService.postOnIOHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { Geocoder geoCoder = new Geocoder(GetLocationActivity.this, Locale.getDefault()); try { List<Address> addresses = geoCoder.getFromLocationName(addressText, 5); if (addresses.size() > 0) { Address address = addresses.get(0); final Location location = new Location(""); location.setLatitude(address.getLatitude()); location.setLongitude(address.getLongitude()); mService.postOnUIHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { pd.dismiss(); mLocation = location; showMap(); } }); return; } } catch (IOException e) { L.d("Failed to geo code address " + addressText, e); } mService.postOnUIHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { pd.dismiss(); UIUtils.showLongToast(GetLocationActivity.this, getString(R.string.failed_to_lookup_address)); } }); } }); } }); }
From source file:com.hx.hxchat.activity.ContactlistFragment.java
/** * ?// ww w .j a v a2 s. co m * * @param toDeleteUser */ public void deleteContact(final User tobeDeleteUser) { final ProgressDialog pd = CommonUtils.getProgrossDialog(getActivity(), "...", false); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { @Override public void run() { try { JSONObject oJSONObject = UserUtils.delfriend(getActivity(), tobeDeleteUser.getUsername()); if (oJSONObject != null) { if (oJSONObject.getString("flag").equals("0")) { // db? UserDao dao = new UserDao(getActivity()); dao.deleteContact(tobeDeleteUser.getUsername()); BaseApplication.getApplication().getContactList().remove(tobeDeleteUser.getUsername()); getActivity().runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); adapter.remove(tobeDeleteUser); Define_C.s_HasChangeContent = true; adapter.notifyDataSetChanged(); } }); EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername()); } else { getActivity().runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); Toast.makeText(getActivity(), "", 1).show(); } }); } } else { getActivity().runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); Toast.makeText(getActivity(), "", 1).show(); } }); } } catch (final Exception e) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); Toast.makeText(getActivity(), "" + e.getMessage(), 1).show(); } }); } } }).start(); }
From source file:ztc1997.gxmu.teachingassessment.ui.ResetPwdActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_reset_pwd); password = (EditText) findViewById(R.id.password); check = (EditText) findViewById(R.id.check); btnResetPwd = (Button) findViewById(R.id.btn_reset_pwd); btnResetPwd.setOnClickListener(view -> { String pwd = password.getText().toString(); String pwd2 = check.getText().toString(); if (!pwd.equals(pwd2)) { check.setError(getString(R.string.error_reset_pwd_not_equals)); return; }// ww w .j ava 2 s .c om if (pwd.length() < 4) { password.setError(getString(R.string.error_reset_pwd_too_short)); return; } ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setCancelable(false); progressDialog.setMessage(getString(R.string.msg_reseting_pwd)); progressDialog.show(); new AlertDialog.Builder(this).setPositiveButton(android.R.string.ok, ((dialog, which) -> { Map<String, String> params = new HashMap<>(); params.put("roleNum", BaseApplication.getStudentLoginInfo().getRoleNum()); params.put("studentId", BaseApplication.getStudentLoginInfo().getStudentId()); params.put("newPwd", pwd); StringRequest request = new StringRequest(Request.Method.POST, PostUtils.mergeUrlActionParams("doResetPwdMobile", params), response -> { try { JSONObject jsonObject = new JSONArray(response).getJSONObject(0); if ("ok".equals(jsonObject.getString("res"))) { Toast.makeText(ResetPwdActivity.this, R.string.msg_reset_pwd_sucess, Toast.LENGTH_SHORT).show(); finish(); return; } password.setError(getString(R.string.error_reset_pwd_failed)); } catch (JSONException e) { e.printStackTrace(); } }, e -> { CrashReport.postCatchedException(e); progressDialog.dismiss(); Toast.makeText(this, R.string.error_network_timeout, Toast.LENGTH_SHORT).show(); }); request.setTag(TAG); BaseApplication.getRequestQueue().add(request); })).setNegativeButton(android.R.string.cancel, null).setTitle(R.string.title_dialog_reset_pwd) .setMessage(R.string.msg_dialog_reset_pwd).show(); }); }
From source file:jp.co.rediscovery.arflight.ManagerFragment.java
/** * ??IDeviceController?// w w w. ja va 2s. co m * @param controller */ protected void stopController(final IDeviceController controller) { runOnUiThread(new Runnable() { @Override public void run() { final boolean show_progress = controller.isStarted(); final ProgressDialog dialog; if (show_progress) { dialog = new ProgressDialog(getActivity()); dialog.setTitle(R.string.disconnecting); dialog.setIndeterminate(true); dialog.show(); } else { dialog = null; } queueEvent(new Runnable() { @Override public void run() { try { controller.stop(); } catch (final Exception e) { Log.w(TAG, e); } if (dialog != null) { runOnUiThread(new Runnable() { @Override public void run() { dialog.dismiss(); } }); } } }); } }); }
From source file:org.messic.android.smartphone.activities.main.MainActivity.java
private void emptyDatabaseAction() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: DialogInterface.OnClickListener reallySure = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: final ProgressDialog pd = ProgressDialog.show(MainActivity.this, MainActivity.this.getString(R.string.action_emptying_localdatabase_title), MainActivity.this.getString(R.string.action_emptying_localdatabase_content), true); Observable<Void> observable = presenter.emptyDatabase(); observable.subscribeOn(Schedulers.io()).onBackpressureBuffer() .observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Void>() { @Override public void call(Void aVoid) { } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { throwable.printStackTrace(); Timber.e(throwable.getMessage(), throwable); Toast.makeText(MainActivity.this, "Error!", Toast.LENGTH_LONG) .show(); pd.dismiss(); } }, new Action0() { @Override public void call() { pd.dismiss(); } });/*from ww w. j a v a 2 s. c o m*/ break; case DialogInterface.BUTTON_NEGATIVE: // No button clicked break; } } }; builder.setMessage(getString(R.string.action_empty_localdatabase_reallysure)); builder.setPositiveButton(getString(R.string.yes), reallySure); builder.setNegativeButton(getString(R.string.no), reallySure); builder.show(); break; case DialogInterface.BUTTON_NEGATIVE: // No button clicked break; } } }; builder.setMessage(getString(R.string.action_empty_localdatabase)); builder.setPositiveButton(getString(R.string.yes), dialogClickListener); builder.setNegativeButton(getString(R.string.no), dialogClickListener); builder.show(); }
From source file:com.github.guwenk.smuradio.SignInDialog.java
private void uploadFile() { if (filepath != null) { Log.d(AuthTag, "UPLOAD FILE " + filepath); final ProgressDialog progressDialog = new ProgressDialog(getActivity()); progressDialog.setTitle(getString(R.string.uploading)); progressDialog.setCancelable(false); progressDialog.show();//from w w w .j a v a 2 s.co m int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } Log.d(AuthTag, "UPLOAD FILE progress dialog showing"); StorageReference musicRef = mStorageRef.child("audio/" + songTitle); Log.d(AuthTag, "UPLOAD FILE storage referense: " + musicRef); try { user = mAuth.getCurrentUser(); } catch (Exception ignored) { } StorageMetadata metadata = new StorageMetadata.Builder().setCustomMetadata("By", user.getUid()).build(); musicRef.putFile(filepath, metadata) .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { // if upload success progressDialog.dismiss(); Toast.makeText(getActivity(), R.string.file_uploaded, Toast.LENGTH_SHORT).show(); alert.dismiss(); Log.d(AuthTag, "UPLOAD FILE success"); getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { // if upload failed progressDialog.dismiss(); Toast.makeText(getActivity(), getString(R.string.uploading_error) + exception.getMessage(), Toast.LENGTH_SHORT).show(); alert.dismiss(); Log.d(AuthTag, "UPLOAD FILE FAILED"); getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } }).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() { @Override public void onProgress(UploadTask.TaskSnapshot taskSnapshot) { double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount(); try { progressDialog.setMessage((int) progress + getString(R.string.uploaded_procents)); Log.d(AuthTag, "UPLOAD FILE progress update: " + progress); } catch (Exception e) { e.printStackTrace(); } } }); } else { Toast.makeText(getActivity(), R.string.wrong_file, Toast.LENGTH_SHORT).show(); } }
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);/* w w w. j ava 2s . c o m*/ dialog.setCancelable(false); 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:de.mkrtchyan.recoverytools.FlashFragment.java
public void showUnifiedBuildsDialog() { final AppCompatDialog UnifiedBuildsDialog = new AppCompatDialog(mContext); UnifiedBuildsDialog.setTitle(R.string.make_choice); final ArrayList<String> DevName = new ArrayList<>(); ArrayList<String> DevNamesCarriers = new ArrayList<>(); UnifiedBuildsDialog.setContentView(R.layout.dialog_unified_build); ListView UnifiedList = (ListView) UnifiedBuildsDialog.findViewById(R.id.lvUnifiedList); ArrayAdapter<String> UnifiedAdapter = new ArrayAdapter<>(mContext, android.R.layout.simple_list_item_1, DevNamesCarriers);//from w w w . j a v a 2 s . c om UnifiedList.setAdapter(UnifiedAdapter); if (mDevice.getManufacture().equals("samsung")) { String[] unifiedGalaxyS3 = { "d2lte", "d2att", "d2cri", "d2mtr", "d2spr", "d2tmo", "d2usc", "d2vzw" }; String[] unifiedGalaxyNote3 = { "hlte", "hltespr", "hltetmo", "hltevzw", "htlexx" }; String[] unifiedGalaxyS4 = { "jflte", "jflteatt", "jfltecan", "jfltecri", "jfltecsp", "jfltespr", "jfltetmo", "jflteusc", "jfltevzw", "jfltexx", "jgedlte" }; if (Common.stringEndsWithArray(mDevice.getName(), unifiedGalaxyS3)) { DevName.addAll(Arrays.asList(unifiedGalaxyS3)); } else if (Common.stringEndsWithArray(mDevice.getName(), unifiedGalaxyS3)) { DevName.addAll(Arrays.asList(unifiedGalaxyNote3)); } else if (Common.stringEndsWithArray(mDevice.getName(), unifiedGalaxyS4)) { DevName.addAll(Arrays.asList(unifiedGalaxyS4)); } } if (mDevice.getManufacture().equals("motorola")) { String[] unifiedMsm8960 = { "moto_msm8960" }; if (mDevice.getBOARD().equals("msm8960")) { DevName.addAll(Arrays.asList(unifiedMsm8960)); } } for (String i : DevName) { if (i.contains("att")) { DevNamesCarriers.add(i + " (AT&T Mobility)"); } else if (i.contains("can")) { DevNamesCarriers.add(i + " (Canada)"); } else if (i.contains("cri")) { DevNamesCarriers.add(i + " (Cricket Wireless)"); } else if (i.contains("csp")) { DevNamesCarriers.add(i + " (C Spire Wireless)"); } else if (i.contains("mtr")) { DevNamesCarriers.add(i + " (MetroPCS)"); } else if (i.contains("spr")) { DevNamesCarriers.add(i + " (Sprint Corporation)"); } else if (i.contains("tmo")) { DevNamesCarriers.add(i + " (T-Mobile US)"); } else if (i.contains("usc")) { DevNamesCarriers.add(i + " (U.S. Cellular)"); } else if (i.contains("vzw")) { DevNamesCarriers.add(i + " (Verizon Wireless)"); } else if (i.contains("xx")) { DevNamesCarriers.add(i + " (International)"); } else if (i.contains("ged")) { DevNamesCarriers.add(i + " (Google Play Edition)"); } else { DevNamesCarriers.add(i + " (Unified)"); } } UnifiedList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int position, long id) { UnifiedBuildsDialog.dismiss(); final ProgressDialog reloading = new ProgressDialog(mContext); reloading.setMessage(mContext.getString(R.string.reloading)); reloading.setCancelable(false); reloading.show(); new Thread(new Runnable() { @Override public void run() { Common.setBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_SHOW_UNIFIED, false); mDevice.setName(DevName.get(position)); mDevice.loadRecoveryList(); mActivity.runOnUiThread(new Runnable() { @Override public void run() { reloading.dismiss(); mActivity.switchTo(FlashFragment.newInstance(mActivity)); } }); } }).start(); } }); AppCompatButton KeepCurrent = (AppCompatButton) UnifiedBuildsDialog.findViewById(R.id.bKeepCurrent); KeepCurrent.setText(String.format(getString(R.string.keep_current_name), mDevice.getName())); KeepCurrent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Common.setBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_SHOW_UNIFIED, false); UnifiedBuildsDialog.dismiss(); } }); if (DevName.size() > 0) { UnifiedBuildsDialog.show(); UnifiedBuildsDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { Common.setBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_SHOW_UNIFIED, false); } }); } }