List of usage examples for android.app ProgressDialog dismiss
@Override public void dismiss()
From source file:nl.eduvpn.app.fragment.HomeFragment.java
private void _checkCertificateValidity(Instance instance, DiscoveredAPI discoveredAPI, SavedKeyPair savedKeyPair, Profile profile, AuthState authState, ProgressDialog dialog) { String commonName = savedKeyPair.getKeyPair().getCertificateCommonName(); if (commonName == null) { // Unable to check, better download it again. _historyService.removeSavedKeyPairs(instance); // Try downloading it again. dialog.dismiss(); _downloadKeyPairIfNeeded(instance, discoveredAPI, profile, authState); Log.w(TAG, "Could not check if certificate is valid. Downloading again."); }//from ww w. java 2 s. com _apiService.getJSON(discoveredAPI.getCheckCertificateEndpoint(commonName), authState, new APIService.Callback<JSONObject>() { @Override public void onSuccess(JSONObject result) { try { Boolean isValid = result.getJSONObject("check_certificate").getJSONObject("data") .getBoolean("is_valid"); if (isValid) { Log.i(TAG, "Certificate appears to be valid."); _downloadProfileWithKeyPair(instance, discoveredAPI, savedKeyPair, profile, authState, dialog); } else { dialog.dismiss(); String reason = result.getJSONObject("check_certificate").getJSONObject("data") .getString("reason"); if ("user_disabled".equals(reason) || "certificate_disabled".equals(reason)) { int errorStringId = R.string.error_certificate_disabled; if ("user_disabled".equals(reason)) { errorStringId = R.string.error_user_disabled; } _currentDialog = ErrorDialog.show(getContext(), R.string.error_dialog_title_invalid_certificate, getString(errorStringId)); } else { // Remove stored keypair. _historyService.removeSavedKeyPairs(instance); Log.i(TAG, "Certificate is invalid. Fetching new one. Reason: " + reason); // Try downloading it again. _downloadKeyPairIfNeeded(instance, discoveredAPI, profile, authState); } } } catch (Exception ex) { dialog.dismiss(); _currentDialog = ErrorDialog.show(getContext(), R.string.error_dialog_title, getString(R.string.error_parsing_certificate)); Log.e(TAG, "Unexpected certificate call response!", ex); } } @Override public void onError(String errorMessage) { dialog.dismiss(); if (errorMessage != null && (APIService.USER_NOT_AUTHORIZED_ERROR.equals(errorMessage) || errorMessage.contains("invalid_grant"))) { // Display a dialog with all the warnings _currentDialog = ErrorDialog.show(getContext(), getString(R.string.warnings_list), getString(R.string.instance_access_warning_message), new ErrorDialog.InstanceWarningHandler() { @Override public List<Instance> getInstances() { return Collections.singletonList(instance); } @Override public void retryInstance(Instance instance) { SavedAuthState savedAuthState = _historyService.getSavedToken(instance); if (savedAuthState == null) { // Should never happen _currentDialog = ErrorDialog.show(getContext(), R.string.error_dialog_title, R.string.data_removed); } else { int dialogMessageRes = R.string.vpn_profile_checking_certificate; final ProgressDialog dialog = ProgressDialog.show(getContext(), getString(R.string.progress_dialog_title), getString(dialogMessageRes), true, false); dialog.show(); _currentDialog = dialog; _checkCertificateValidity(instance, discoveredAPI, savedKeyPair, profile, savedAuthState.getAuthState(), dialog); } } @Override public void loginInstance(final Instance instance) { // Find the auth state for the instance and then retry AuthState authState = _historyService.getCachedAuthState(instance); _apiService.getJSON( instance.getSanitizedBaseURI() + Constants.API_DISCOVERY_POSTFIX, authState, new APIService.Callback<JSONObject>() { @Override public void onSuccess(JSONObject result) { try { DiscoveredAPI discoveredAPI = _serializerService .deserializeDiscoveredAPI(result); // Cache the result _historyService.cacheDiscoveredAPI( instance.getSanitizedBaseURI(), discoveredAPI); _connectionService.initiateConnection(getActivity(), instance, discoveredAPI); } catch (SerializerService.UnknownFormatException ex) { Log.e(TAG, "Error parsing discovered API!", ex); _currentDialog = ErrorDialog.show(getContext(), R.string.error_dialog_title, R.string.provider_incorrect_format); } } @Override public void onError(String errorMessage) { Log.e(TAG, "Error while fetching discovered API: " + errorMessage); DiscoveredAPI discoveredAPI = _historyService .getCachedDiscoveredAPI( instance.getSanitizedBaseURI()); Activity activity = getActivity(); if (discoveredAPI != null && activity != null && !activity.isFinishing()) { _connectionService.initiateConnection(activity, instance, discoveredAPI); } else { _currentDialog = ErrorDialog.show(getContext(), R.string.error_dialog_title, R.string.provider_not_found_retry); } } }); } @Override public void removeInstance(Instance instance) { _historyService.removeAllDataForInstance(instance); } }); } else { _currentDialog = ErrorDialog.show(getContext(), R.string.error_dialog_title, getString(R.string.error_checking_certificate)); Log.e(TAG, "Error checking certificate: " + errorMessage); } } }); }
From source file:com.shengtao.chat.chatUI.activity.ContactlistFragment.java
/** * ?//from ww w . j a v a2 s . c o m * * @param toDeleteUser */ public void deleteContact(final User tobeDeleteUser) { String st1 = getResources().getString(R.string.deleting); final String st2 = getResources().getString(R.string.Delete_failed); final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername()); // db? UserDao dao = new UserDao(getActivity()); dao.deleteContact(tobeDeleteUser.getUsername()); UIApplication.getContext().getContactList().remove(tobeDeleteUser.getUsername()); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); } }); } catch (final Exception e) { getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2 + e.getMessage(), Toast.LENGTH_SHORT).show(); } }); } } }).start(); }
From source file:cn.ucai.SuperWechat.activity.SettingsFragment.java
void logout() { final ProgressDialog pd = new ProgressDialog(getActivity()); String st = getResources().getString(R.string.Are_logged_out); pd.setMessage(st);// ww w. j a v a 2s .c o m pd.setCanceledOnTouchOutside(false); pd.show(); DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() { @Override public void onSuccess() { getActivity().runOnUiThread(new Runnable() { public void run() { SuperWeChatApplication.getInstance().getStringUserAvatarMap().clear(); SuperWeChatApplication.getInstance().getUserAvatars().clear(); SuperWeChatApplication.getInstance().getGroupList().clear(); SuperWeChatApplication.getInstance().setUserAvatar(null); pd.dismiss(); // ?? ((MainActivity) getActivity()).finish(); startActivity(new Intent(getActivity(), LoginActivity.class)); } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub pd.dismiss(); Toast.makeText(getActivity(), "unbind devicetokens failed", Toast.LENGTH_SHORT).show(); } }); } }); }
From source file:com.kopysoft.chronos.activities.ClockActivity.java
private void sendEmail() { //PayPeriodHolder payPeriodHolder, Job thisJob, Context context ProgressDialog dialog = ProgressDialog.show(ClockActivity.this, "", "Generating. Please wait..."); PayPeriodHolder pph;/*from w w w. j ava 2 s .c om*/ if (getSupportActionBar().getSelectedTab().getPosition() == 0) { pph = new PayPeriodHolder(jobId); } else { pph = payHolder; } Email newEmail = new Email(pph, jobId, getApplicationContext()); SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); int reportLevel = Integer.valueOf(pref.getString("reportLevel", "1")); String returnValue; if (reportLevel == 2) { returnValue = newEmail.getBriefView(); } else { returnValue = newEmail.getExpandedView(); } String emailBody = new String("Greetings!\n\tHere is my time card\n"); emailBody += returnValue; dialog.dismiss(); //Create email Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Time Card"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailBody); emailIntent.setType("message/rfc822"); startActivity(emailIntent); }
From source file:com.lykj.weixun.ui.chat.ui.ContactListFragment.java
/** * delete contact/*from ww w . ja v a 2 s. com*/ * * @param */ public void deleteContact(final EaseUser tobeDeleteUser) { String st1 = getResources().getString(R.string.deleting); final String st2 = getResources().getString(R.string.Delete_failed); final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { EMClient.getInstance().contactManager().deleteContact(tobeDeleteUser.getUsername()); // remove user from memory and database UserDao dao = new UserDao(getActivity()); dao.deleteContact(tobeDeleteUser.getUsername()); DemoHelper.getInstance().getContactList().remove(tobeDeleteUser.getUsername()); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); contactList.remove(tobeDeleteUser); contactListLayout.refresh(); } }); } catch (final Exception e) { getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2 + e.getMessage(), Toast.LENGTH_LONG).show(); } }); } } }).start(); }
From source file:com.huison.DriverAssistant_Web.util.LoginHelper.java
public static void forgetPassword(final BaseActivity activity, final String username) { UmengEventSender.sendEvent(activity, UmengEventTypes.forgetPW); final ProgressDialog pd = new ProgressDialog(activity); pd.setMessage(""); pd.show();/* w w w. j ava 2s. c om*/ AsyncHttpClient client = activity.getAsyncHttpClient(); RequestParams params = new RequestParams(); /* * Map<String, String> map = new HashMap<String, String>(); * map.put("sessionkey", BaseActivity.getSESSIONKEY()); * map.put("userid", username); map.put("mob", phone); * map.put("version", activity.getVersionName()); params.put("action", * FORGET_PASSWORD_ACTION); params.put("xml", BaseActivity.getXML(map)); * Log.v("XML:",BaseActivity.getXML(map)); */ try { JSONObject p = new JSONObject(); p.put("mobile", username); p.put("password", "wangjile"); p.put("method", "forget"); p.put("version", activity.getVersionName()); p.put("devicetype", "android"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date curDate = new Date(System.currentTimeMillis());// String time = formatter.format(curDate); p.put("time", time); Log.v("", p.toString()); String data = Util.DesJiaMi(p.toString(), "czxms520"); // Log.v("",data); params.put("data", data); } catch (Exception e) { e.printStackTrace(); } client.post(BaseActivity.REQUESTURL, params, new JsonHttpResponseHandler() { @Override public void onDispatchSuccess(int statusCode, Header[] headers, String result) { pd.dismiss(); try { result = Util.decrypt(result, "czxms520"); Log.v(TAG, "JSON" + result); JSONObject jo = new JSONObject(result); String code = jo.getString("code"); String msg = getJSONValueAsString(jo, "message"); if (code.equals("0")) { activity.showMessageBoxAndFinish(msg); } else { activity.showMessageBox(msg); } } catch (JSONException e) { activity.showMessageBox(activity.getText(R.string.server404)); Log.e("change password error", Log.getStackTraceString(e)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onFailureAnyway(int statusCode, Header[] headers, Throwable throwable, BaseBinaryResponse jsonResponse) { pd.dismiss(); activity.showMessageBox(activity.getText(R.string.server404)); } @Override public void onSuccessAnyway(int statusCode, Header[] headers, BaseBinaryResponse jsonResponse) { } }); TimeCounter.countTime(activity, pd); }
From source file:com.hzx.luoyechat.activity.ContactlistFragment.java
/** * user???/* ww w .j av a2 s .c o m*/ */ private void moveToBlacklist(final String username) { final ProgressDialog pd = new ProgressDialog(getActivity()); String st1 = getResources().getString(R.string.Is_moved_into_blacklist); final String st2 = getResources().getString(R.string.Move_into_blacklist_success); final String st3 = getResources().getString(R.string.Move_into_blacklist_failure); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { //??? EMContactManager.getInstance().addUserToBlackList(username, false); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2, Toast.LENGTH_SHORT).show(); refresh(); } }); } catch (EaseMobException e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st3, 0).show(); } }); } } }).start(); }
From source file:com.example.research.whatis.MainActivity.java
public String invokeOCRAPI() throws IOException, JSONException { // String license_code = "31CB2366-603F-4F19-BEFB-1C961348DBA0"; // String user_name = "VIVEKHARIKRISHNANR"; // String ocrURL = "http://www.ocrwebservice.com/restservices/processDocument?gettext=true"; // Toast.makeText(this, "Invoking OCR", Toast.LENGTH_LONG).show(); Log.d("API", "Inokving OCR: "); final ProgressDialog dialog = ProgressDialog.show(MainActivity.this, "Loading ...", "Converting to text.", true, false);// w w w. j a v a2s. com final Thread thread = new Thread(new Runnable() { @Override public void run() { String apiKey = "nh9tSJg3Mf"; String langCode = "en"; final OCRServiceAPI apiClient = new OCRServiceAPI(apiKey); apiClient.convertToText(langCode, sdImageMainDirectory.getPath()); // Doing UI related code in UI thread runOnUiThread(new Runnable() { @Override public void run() { dialog.dismiss(); // Showing response dialog // final AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this); // alert.setMessage(apiClient.getResponseText()); OCRedText = apiClient.getResponseText(); OCRedText = OCRedText.replaceAll("\\W", ""); Log.e("OCRedText", OCRedText); try { invokeSynonymsAPI(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } // alert.setPositiveButton( // "OK", // new DialogInterface.OnClickListener() { // public void onClick( DialogInterface dialog, int id) { // } // }); // //// Setting dialog title related from response code // if (apiClient.getResponseCode() == 200) { // alert.setTitle("Success"); // } else { // alert.setTitle("Faild"); // } // // alert.show(); } }); } }); thread.start(); // //MediaStore.Files.getContentUri(Uri.fromFile(sdImageMainDirectory).toString()); // byte bytes[] = FileUtils.readFileToByteArray(sdImageMainDirectory); // // // URL url = new URL(ocrURL); // HttpURLConnection connection = (HttpURLConnection) url.openConnection(); // connection.setDoOutput(true); // connection.setDoInput(true); // connection.setRequestMethod("POST"); // connection.setRequestProperty("Authorization", "Basic " + Base64.encodeToString((user_name + ":" + license_code).getBytes(), Base64.DEFAULT)); // connection.setRequestProperty("Content-Type", "application/json"); // connection.setRequestProperty("Content-Length", Integer.toString(bytes.length)); // // Toast.makeText(this, "OCR Connection" + connection.toString(), Toast.LENGTH_LONG).show(); // Log.d("API", "OCR Connection: " + connection.toString()); // // OutputStream stream = connection.getOutputStream(); // stream.write(bytes); // stream.close(); // // int httpCode = connection.getResponseCode(); // // Success request // if (httpCode == HttpURLConnection.HTTP_OK) { // Log.d("OCR API", "Success"); // // Get response stream // String jsonResponse = GetResponseToString(connection.getInputStream()); // JSONObject reader = new JSONObject(jsonResponse); // JSONArray text = reader.getJSONArray("OCRText"); // Log.d("OCR API", text.toString()); // if (text.length() > 0) { // OCRedText = text.get(0).toString(); // } else { // OCRedText = ""; // } // // File root = new File(Environment // .getExternalStorageDirectory() // + File.separator + "WhatisCache" + File.separator); // root.mkdirs(); // File f = new File(root, "OCRedText.txt"); // // FileWriter writer = new FileWriter(f); // writer.append(OCRedText); // writer.flush(); // writer.close(); // } else if (httpCode == HttpURLConnection.HTTP_UNAUTHORIZED) { // Log.d("OCR API", "OCR Error Message: Unauthorizied request"); // System.out.println("OCR Error Message: Unauthorizied request"); // } else { // // Error occurred // String jsonResponse = GetResponseToString(connection.getErrorStream()); // // JSONObject reader = new JSONObject(jsonResponse); // JSONArray text = reader.getJSONArray("ErrorMessage"); // Log.d("OCR API", "OCR Error"); // Log.d("OCR API", text.toString()); // // OCRedText = text.get(0).toString(); // // Error message // Toast.makeText(MainActivity.this, "Error Message: " + OCRedText, Toast.LENGTH_LONG).show(); // System.out.println(); // } // // connection.disconnect(); //OCRedText = "happy"; return OCRedText; }
From source file:com.eason.marker.emchat.chatuidemo.activity.ContactlistFragment.java
/** * user???/*from ww w .j a va2s .com*/ */ private void moveToBlacklist(final String username) { final ProgressDialog pd = new ProgressDialog(getActivity()); String st1 = getResources().getString(R.string.Is_moved_into_blacklist); final String st2 = getResources().getString(R.string.Move_into_blacklist_success); final String st3 = getResources().getString(R.string.Move_into_blacklist_failure); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { //??? EMContactManager.getInstance().addUserToBlackList(username, false); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); GreenToast.makeText(getActivity(), st2, 0).show(); refresh(); } }); } catch (EaseMobException e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); GreenToast.makeText(getActivity(), st3, 0).show(); } }); } } }).start(); }
From source file:cmu.cconfs.instantMessage.activities.ContactlistFragment.java
/** * user???/*from w ww.j av a2 s. c o m*/ */ private void moveToBlacklist(final String username) { final ProgressDialog pd = new ProgressDialog(getActivity()); String st1 = getResources().getString(R.string.Is_moved_into_blacklist); final String st2 = getResources().getString(R.string.Move_into_blacklist_success); final String st3 = getResources().getString(R.string.Move_into_blacklist_failure); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { //??? EMContactManager.getInstance().addUserToBlackList(username, false); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2, 0).show(); refresh(); } }); } catch (EaseMobException e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st3, 0).show(); } }); } } }).start(); }