List of usage examples for android.app ProgressDialog dismiss
@Override public void dismiss()
From source file:de.ub0r.android.callmeter.ui.prefs.Preferences.java
/** * Import data previously exported./* w w w . j av a 2s .co m*/ * * @param context * {@link Context} * @param uri * {@link Uri} */ private void importData(final Context context, final Uri uri) { Log.d(TAG, "importData(ctx, " + uri + ")"); final ProgressDialog d1 = new ProgressDialog(this); d1.setCancelable(true); d1.setMessage(this.getString(R.string.import_progr)); d1.setIndeterminate(true); d1.show(); new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(final Void... params) { StringBuilder sb = new StringBuilder(); try { final BufferedReader bufferedReader = // . new BufferedReader(new InputStreamReader(// . Preferences.this.getStream(Preferences.this.getContentResolver(), uri)), BUFSIZE); String line = bufferedReader.readLine(); while (line != null) { sb.append(line); sb.append("\n"); line = bufferedReader.readLine(); } } catch (Exception e) { Log.e(TAG, "error in reading export: " + e.toString(), e); return null; } return sb.toString(); } @Override protected void onPostExecute(final String result) { Log.d(TAG, "import:\n" + result); d1.dismiss(); if (result == null || result.length() == 0) { Toast.makeText(Preferences.this, R.string.err_export_read, Toast.LENGTH_LONG).show(); return; } String[] lines = result.split("\n"); if (lines.length <= 2) { Toast.makeText(Preferences.this, R.string.err_export_read, Toast.LENGTH_LONG).show(); return; } Builder builder = new Builder(Preferences.this); builder.setCancelable(true); builder.setTitle(R.string.import_rules_); builder.setMessage(Preferences.this.getString(R.string.import_rules_hint) + "\n" + URLDecoder.decode(lines[1])); builder.setNegativeButton(android.R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { d1.setCancelable(false); d1.setIndeterminate(true); d1.show(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(final Void... params) { DataProvider.importData(Preferences.this, result); return null; } @Override protected void onPostExecute(final Void result) { de.ub0r.android.callmeter.ui.Plans.reloadList(); d1.dismiss(); } } // . .execute((Void) null); } }); builder.show(); } } // . .execute((Void) null); }
From source file:com.robotcontrol.activity.ChatActivity.java
protected void onChatRoomViewCreation() { findViewById(R.id.container_to_group).setVisibility(View.GONE); final ProgressDialog pd = ProgressDialog.show(this, "", "Joining......"); EMChatManager.getInstance().joinChatRoom(toChatUsername, new EMValueCallBack<EMChatRoom>() { @Override//from ww w. j a v a 2 s. c o m public void onSuccess(EMChatRoom value) { runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); room = EMChatManager.getInstance().getChatRoom(toChatUsername); if (room != null) { ((TextView) findViewById(R.id.name)).setText(room.getName()); } else { ((TextView) findViewById(R.id.name)).setText(toChatUsername); } EMLog.d(TAG, "join room success : " + room.getName()); onConversationInit(); onListViewCreation(); } }); } @Override public void onError(final int error, String errorMsg) { EMLog.d(TAG, "join room failure : " + error); runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); } }); finish(); } }); }
From source file:com.jakebasile.android.linkshrink.ShortenUrl.java
private void shortenWithGoogl(final String longUrl) { String display = String.format(getResources().getString(R.string.shortening_message), GOOGL); final ProgressDialog pd = ProgressDialog.show(ShortenUrl.this, getResources().getString(R.string.shortening_title), display, true); new Thread() { @Override//from w w w . ja v a2 s . c o m public void run() { try { JSONObject request = new JSONObject(); request.put("longUrl", longUrl); HttpClient httpClient = new DefaultHttpClient(); HttpPost post = new HttpPost(new URI(GOOGL_URL)); HttpEntity entity = new StringEntity(request.toString()); post.setEntity(entity); post.setHeader("Content-Type", "application/json"); HttpResponse response = httpClient.execute(post); if (response.getStatusLine().getStatusCode() == 200) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); response.getEntity().writeTo(stream); String jsonMessage = new String(stream.toByteArray()); Log.v("linkshrink", jsonMessage); JSONObject googlResponse = new JSONObject(jsonMessage); _shortUrl = googlResponse.getString("id"); } else { _shortUrl = null; } _handler.sendEmptyMessage(0); } catch (IOException ex) { _handler.sendEmptyMessage(1); Log.e("linkshrink", ex.getMessage()); } catch (URISyntaxException ex) { _handler.sendEmptyMessage(2); Log.e("linkshrink", ex.getMessage()); } catch (JSONException ex) { // nothing Log.e("linkshrink", ex.getMessage()); } finally { pd.dismiss(); } } }.start(); }
From source file:com.youti.chat.activity.ChatActivity.java
protected void onChatRoomViewCreation() { findViewById(R.id.container_to_group).setVisibility(View.GONE); final ProgressDialog pd = ProgressDialog.show(this, "", "Joining......"); EMChatManager.getInstance().joinChatRoom(toTel, new EMValueCallBack<EMChatRoom>() { @Override/*from www . j av a 2 s. com*/ public void onSuccess(EMChatRoom value) { // TODO Auto-generated method stub runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); room = EMChatManager.getInstance().getChatRoom(toTel); if (room != null) { ((TextView) findViewById(R.id.name)).setText(room.getName()); } else { ((TextView) findViewById(R.id.name)).setText(toTel); } EMLog.d(TAG, "join room success : " + room.getName()); onConversationInit(); onListViewCreation(); } }); } @Override public void onError(final int error, String errorMsg) { // TODO Auto-generated method stub EMLog.d(TAG, "join room failure : " + error); runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); } }); finish(); } }); }
From source file:cn.ucai.yizhesale.activity.ChatActivity.java
/** * ???/*from w w w . j a v a2 s . co m*/ * * @param username */ private void addUserToBlacklist(final String username) { final ProgressDialog pd = new ProgressDialog(this); pd.setMessage(getString(cn.ucai.yizhesale.R.string.Is_moved_into_blacklist)); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { EMContactManager.getInstance().addUserToBlackList(username, false); runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getApplicationContext(), cn.ucai.yizhesale.R.string.Move_into_blacklist_success, Toast.LENGTH_SHORT) .show(); } }); } catch (EaseMobException e) { e.printStackTrace(); runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getApplicationContext(), cn.ucai.yizhesale.R.string.Move_into_blacklist_failure, Toast.LENGTH_SHORT) .show(); } }); } } }).start(); }
From source file:cmu.cconfs.instantMessage.activities.ChatActivity.java
protected void onChatRoomViewCreation() { findViewById(R.id.container_to_group).setVisibility(View.GONE); final ProgressDialog pd = ProgressDialog.show(this, "", "Joining......"); EMChatManager.getInstance().joinChatRoom(toChatUsername, new EMValueCallBack<EMChatRoom>() { @Override/*from w w w. j a v a 2 s.c o m*/ public void onSuccess(EMChatRoom value) { // TODO Auto-generated method stub runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); room = EMChatManager.getInstance().getChatRoom(toChatUsername); if (room != null) { ((TextView) findViewById(R.id.name)).setText(room.getName()); } else { ((TextView) findViewById(R.id.name)).setText(toChatUsername); } EMLog.d(TAG, "join room success : " + room.getName()); onConversationInit(); onListViewCreation(); } }); } @Override public void onError(final int error, String errorMsg) { // TODO Auto-generated method stub EMLog.d(TAG, "join room failure : " + error); runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); } }); finish(); } }); }
From source file:cn.gen.superwechat.activity.ChatActivity.java
protected void onChatRoomViewCreation() { final ProgressDialog pd = ProgressDialog.show(this, "", "Joining......"); EMChatManager.getInstance().joinChatRoom(toChatUsername, new EMValueCallBack<EMChatRoom>() { @Override//from w w w .j a v a2 s . com public void onSuccess(EMChatRoom value) { // TODO Auto-generated method stub runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); room = EMChatManager.getInstance().getChatRoom(toChatUsername); if (room != null) { ((TextView) findViewById(cn.gen.superwechat.R.id.name)).setText(room.getName()); } else { ((TextView) findViewById(cn.gen.superwechat.R.id.name)).setText(toChatUsername); } EMLog.d(TAG, "join room success : " + room.getName()); onConversationInit(); onListViewCreation(); } }); } @Override public void onError(final int error, String errorMsg) { // TODO Auto-generated method stub EMLog.d(TAG, "join room failure : " + error); runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); } }); finish(); } }); }
From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java
private void sendRegistrationRequest(final String email) { final ProgressDialog progressDialog = new ProgressDialog(RegistrationActivity2.this); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setMessage(getString(R.string.registration_sending_email, email)); progressDialog.setCancelable(true);//w ww. j a va2 s.co m progressDialog.show(); final SafeRunnable showErrorDialog = new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); progressDialog.dismiss(); AlertDialog.Builder builder = new AlertDialog.Builder(RegistrationActivity2.this); builder.setMessage(R.string.error_please_try_again); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } }; final String timestamp = "" + mWiz.getTimestamp(); final String registrationId = mWiz.getRegistrationId(); final String deviceId = mWiz.getDeviceId(); mWorkerHandler.post(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.REGISTRATION(); String version = "2"; String requestSignature = Security.sha256(version + email + " " + timestamp + " " + deviceId + " " + registrationId + " " + CloudConstants.REGISTRATION_EMAIL_SIGNATURE); HttpPost httppost = new HttpPost(CloudConstants.REGISTRATION_REQUEST_URL); try { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(6); nameValuePairs.add(new BasicNameValuePair("version", version)); nameValuePairs.add(new BasicNameValuePair("email", email)); nameValuePairs.add(new BasicNameValuePair("registration_time", timestamp)); nameValuePairs.add(new BasicNameValuePair("device_id", deviceId)); nameValuePairs.add(new BasicNameValuePair("registration_id", registrationId)); nameValuePairs.add(new BasicNameValuePair("request_signature", requestSignature)); nameValuePairs.add(new BasicNameValuePair("install_id", mWiz.getInstallationId())); nameValuePairs.add(new BasicNameValuePair("request_id", UUID.randomUUID().toString())); nameValuePairs.add(new BasicNameValuePair("language", Locale.getDefault().getLanguage())); nameValuePairs.add(new BasicNameValuePair("country", Locale.getDefault().getCountry())); nameValuePairs.add(new BasicNameValuePair("app_id", CloudConstants.APP_ID)); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request HttpResponse response = mHttpClient.execute(httppost); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == 200) { mUIHandler.post(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); mWiz.setEmail(email); mWiz.save(); progressDialog.dismiss(); mWiz.proceedToNextPage(); showNotification(); } }); } else if (statusCode == 502) { final HttpEntity entity = response.getEntity(); mUIHandler.post(new SafeRunnable() { @Override protected void safeRun() throws Exception { T.UI(); progressDialog.dismiss(); AlertDialog.Builder builder = new AlertDialog.Builder(RegistrationActivity2.this); boolean stringSet = false; if (entity != null) { @SuppressWarnings("unchecked") final Map<String, Object> responseMap = (Map<String, Object>) org.json.simple.JSONValue .parse(new InputStreamReader(entity.getContent())); if (responseMap != null) { String result = (String) responseMap.get("result"); if (result != null) { builder.setMessage(result); stringSet = true; } } } if (!stringSet) { builder.setMessage(R.string.registration_email_not_valid); } builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } }); } else { mUIHandler.post(showErrorDialog); } } catch (ClientProtocolException e) { L.d(e); mUIHandler.post(showErrorDialog); } catch (IOException e) { L.d(e); mUIHandler.post(showErrorDialog); } } }); }
From source file:com.sakisds.icymonitor.activities.AddServerActivity.java
@SuppressWarnings("ConstantConditions") @Override//from w w w. j a va 2 s . c om public void onClick(View view) { // Check if name is empty if (mEditText_name.getText().toString().equals("")) { mEditText_name.setError(getResources().getString(R.string.error_empty_name)); mEditText_name.requestFocus(); } else if (mEditText_port.getText().toString().equals("")) { mEditText_port.setError(getString(R.string.error_empty_port)); mEditText_port.requestFocus(); } else if (mEditText_address.getText().toString().equals("")) { mEditText_address.setError(getString(R.string.error_empty_address)); mEditText_address.requestFocus(); } else { // If it's not // Validate URL String url = mEditText_address.getText().toString(); // Add http:// if needed if (!url.substring(0, 7).equals("http://")) { url = "http://" + url; } url += ":" + mEditText_port.getText().toString(); url = url.replace(" ", ""); if (!URLUtil.isValidUrl(url)) { // If invalid mEditText_address.setError(getResources().getString(R.string.error_invalid_address)); mEditText_address.requestFocus(); } else { // If URL is valid // Create a dialog final ProgressDialog progress = ProgressDialog.show(this, "", getResources().getString(R.string.connecting), false); // Store actual URL final String actualURL = url; // Check if auth is enabled mClient.get(url + "/authEnabled", null, new JsonHttpResponseHandler() { @Override public void onSuccess(JSONObject response) { try { if (response.getBoolean("AuthEnabled")) { progress.setMessage(getString(R.string.check_computer)); } } catch (JSONException ignored) { } // If there are issues they will be dealt with later } }); // Register RequestParams params = new RequestParams(); params.put("name", android.os.Build.MODEL); params.put("id", String.valueOf(mSettings.getLong("device_id", -2))); params.put("gcm", mGCMID); params.put("ask", "true"); JsonHttpResponseHandler handler = new JsonHttpResponseHandler() { @Override public void onSuccess(JSONObject response) { try { // Get string String version = response.getString("Version"); // Parse response if (version.equals(ConnectionActivity.ACCEPTED_SERVER_VERSION)) { String regStatus = response.getString("Status"); if (regStatus.equals("ALLOWED")) { saveServer(actualURL); progress.dismiss(); mResponseReady = true; } else if (regStatus.equals("DENIED")) { mEditText_address.setError(getResources().getString(R.string.error_rejected)); mEditText_address.requestFocus(); progress.dismiss(); mResponseReady = true; } } else { mEditText_address .setError(getResources().getString(R.string.error_outdated_server)); mEditText_address.requestFocus(); progress.dismiss(); mResponseReady = true; } } catch (JSONException e) { mEditText_address.setError(getResources().getString(R.string.error_invalid_response)); mEditText_address.requestFocus(); progress.dismiss(); mResponseReady = true; } } @Override public void onFailure(Throwable e, JSONObject errorResponse) { progress.dismiss(); mEditText_address.setError(getResources().getString(R.string.error_could_not_reach_host)); mEditText_address.requestFocus(); mResponseReady = true; } }; mClient.get(url + "/register", params, handler); params.remove("ask"); WaitingTask task = new WaitingTask(); task.mUrl = url + "/register"; task.mParams = params; task.mHandler = handler; task.execute(); } } }
From source file:cn.hbm.superwechat.activity.ChatActivity.java
protected void onChatRoomViewCreation() { final ProgressDialog pd = ProgressDialog.show(this, "", "Joining......"); EMChatManager.getInstance().joinChatRoom(toChatUsername, new EMValueCallBack<EMChatRoom>() { @Override//from w w w. ja v a2 s . co m public void onSuccess(EMChatRoom value) { // TODO Auto-generated method stub runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); room = EMChatManager.getInstance().getChatRoom(toChatUsername); if (room != null) { ((TextView) findViewById(R.id.name)).setText(room.getName()); } else { ((TextView) findViewById(R.id.name)).setText(toChatUsername); } EMLog.d(TAG, "join room success : " + room.getName()); onConversationInit(); onListViewCreation(); } }); } @Override public void onError(final int error, String errorMsg) { // TODO Auto-generated method stub EMLog.d(TAG, "join room failure : " + error); runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); } }); finish(); } }); }