List of usage examples for android.app ProgressDialog show
public void show()
From source file:Main.java
public static ProgressDialog showProgressDialog(Context context) { ProgressDialog myProgressDialog = new ProgressDialog(context); myProgressDialog.setMessage("Please wait..."); myProgressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); myProgressDialog.show(); myProgressDialog.setCancelable(false); myProgressDialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) { return true; }//from w w w. ja va 2s . co m return false; } }); return myProgressDialog; }
From source file:Main.java
public static ProgressDialog showProgressDialog(Context context, String msg) { ProgressDialog progressDialog = new ProgressDialog(context); if (!TextUtils.isEmpty(msg)) progressDialog.setMessage(msg);//from www. j a va 2 s . co m progressDialog.setIndeterminate(true); progressDialog.setCancelable(false); progressDialog.show(); return progressDialog; }
From source file:Main.java
public static ProgressDialog createProgressDialog(Context mContext) { final ProgressDialog dialog = new ProgressDialog(mContext); try {//from w w w.j a va 2 s . co m Activity a = (Activity) mContext; a.runOnUiThread(new Runnable() { @Override public void run() { dialog.show(); } }); } catch (WindowManager.BadTokenException e) { } dialog.setCancelable(false); return dialog; }
From source file:Main.java
public static ProgressDialog showProgressDialog(Activity context, int message, ProgressDialog.OnCancelListener cancelListener) { ProgressDialog mDialog = new ProgressDialog(context); mDialog.setCancelable(cancelListener != null); mDialog.setOnCancelListener(cancelListener); mDialog.setMessage(context.getString(message)); mDialog.setIndeterminate(true);//from w w w. ja v a2s. c o m mDialog.show(); return mDialog; }
From source file:Main.java
public static ProgressDialog showProgress(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable) { ProgressDialog dialog = new ProgressDialog(context); dialog.setTitle(title);/*w ww . j a v a2s .c o m*/ dialog.setMessage(message); dialog.setIndeterminate(indeterminate); dialog.setCancelable(cancelable); // dialog.setDefaultButton(false); dialog.show(); return dialog; }
From source file:Main.java
public static ProgressDialog showProgressDialog(Context context, String text) { if (null != context) { ProgressDialog dialog = new ProgressDialog(context); dialog.setMessage(text);// w w w .j ava 2 s. c om dialog.setIndeterminate(true); dialog.setCancelable(false); dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); dialog.show(); return dialog; } return null; }
From source file:de.wikilab.android.friendica01.Max.java
/** * Calls the api method <code>verify_credentials</code> with the login data * saved in the <code>SharedPreferences</code>. Calls ctx.OnLogin on success, * showLoginForm(ctx, "error") on error/*from www . j a v a 2 s . c om*/ * @param ctx MUST IMPLEMENT LoginListener !!! */ public static void tryLogin(final Activity ctx) { final ProgressDialog pd = new ProgressDialog(ctx); pd.setMessage(ctx.getResources().getString(R.string.logging_in)); pd.show(); String server = Max.getServer(ctx); Log.i(TAG, "tryLogin on server " + server); final TwAjax t = new TwAjax(ctx, true, true); t.getUrlContent(server + "/api/account/verify_credentials", new Runnable() { @Override public void run() { pd.dismiss(); try { if (t.isSuccess()) { Log.i(TAG, "... tryLogin - http status: " + t.getHttpCode()); if (t.getHttpCode() == 200) { JSONObject r = (JSONObject) t.getJsonResult(); String name = r.getString("name"); ((TextView) ctx.findViewById(R.id.selected_clipboard)).setText(name); ((LoginListener) ctx).OnLogin(); final TwAjax profileImgDl = new TwAjax(); final String targetFs = IMG_CACHE_DIR + "/my_profile_pic_" + r.getString("id") + ".jpg"; if (new File(targetFs).isFile()) { ((ImageView) ctx.findViewById(R.id.profile_image)) .setImageURI(Uri.parse("file://" + targetFs)); } else { profileImgDl.urlDownloadToFile(r.getString("profile_image_url"), targetFs, new Runnable() { @Override public void run() { ((ImageView) ctx.findViewById(R.id.profile_image)) .setImageURI(Uri.parse("file://" + targetFs)); } }); } } else { showLoginForm(ctx, "Error: " + t.getResult()); } } else { Log.w(TAG, "... tryLogin - request failed"); showLoginForm(ctx, "ERR: " + t.getError().toString()); } } catch (Exception ex) { Log.w(TAG, "... tryLogin - exception:"); ex.printStackTrace(); showLoginForm(ctx, "ERR2: " + t.getResult() + ex.toString()); } } }); }
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(); AsyncHttpClient client = activity.getAsyncHttpClient(); RequestParams params = new RequestParams(); /*/*from ww w.j a v a2 s . c om*/ * 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.huison.DriverAssistant_Web.util.LoginHelper.java
public static void changePassword(final BaseActivity activity, final String username, final String phone, final String oldPassword, final String newPassword) { UmengEventSender.sendEvent(activity, UmengEventTypes.changePW); final ProgressDialog pd = new ProgressDialog(activity); pd.setMessage(""); pd.show(); AsyncHttpClient client = activity.getAsyncHttpClient(); RequestParams params = new RequestParams(); /*/*from w w w. j a v a 2 s . c o m*/ * Map<String, String> map = new HashMap<String, String>(); * map.put("sessionkey", BaseActivity.getSESSIONKEY()); * map.put("userid", username); map.put("mob", phone); * map.put("oldpasswork", oldPassword); map.put("passwork", * newPassword); map.put("version", activity.getVersionName()); * params.put("action", CHANGE_PASSWORD_ACTION); params.put("xml", * BaseActivity.getXML(map)); */ try { JSONObject p = new JSONObject(); p.put("mobile", phone); p.put("password", oldPassword); p.put("method", "editpassword"); p.put("version", activity.getVersionName()); p.put("devicetype", "android"); p.put("newpassword", newPassword); 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) { 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")) { // jo = jo.getJSONObject("data"); activity.showMessageBoxAndFinish(msg); activity.setPassword(newPassword); } 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) { pd.dismiss(); // ChangePasswordActivity.instance.finish(); } }); TimeCounter.countTime(activity, pd); }
From source file:com.huison.DriverAssistant_Web.util.LoginHelper.java
public static void login(final BaseActivity activity, final String username, final String password, final boolean autoLogin) { Log.i(TAG, "call login func:" + username + "/" + password); ctx = activity;/* ww w .j a v a 2s .c om*/ UmengEventSender.sendEvent(activity, UmengEventTypes.login); final ProgressDialog pd = new ProgressDialog(activity); pd.setMessage(activity.getString(R.string.logging_wait)); pd.show(); AsyncHttpClient client = activity.getAsyncHttpClient(); RequestParams params = new RequestParams(); try { JSONObject p = new JSONObject(); p.put("mobile", username); p.put("password", password); p.put("method", "login"); 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.i(TAG, "request parameters: " + p.toString()); String data = Util.DesJiaMi(p.toString(), "czxms520"); Log.i(TAG, "post data:" + data); params.put("data", data); } catch (Exception e) { activity.showMessageBox(activity.getString(R.string.wrong_profile)); Log.e(TAG, e.getMessage()); e.printStackTrace(); return; } // params.put("xml", BaseActivity.getXML(map)); Log.i(TAG, "AsyncHttpClient post:" + BaseActivity.REQUESTURL); client.post(BaseActivity.REQUESTURL, params, new JsonHttpResponseHandler() { @Override public void onDispatchSuccess(int statusCode, Header[] headers, String result) { Log.i(TAG, "onDispatchSuccess: " + result); pd.dismiss(); try { Log.i(TAG, "decrypting..."); result = Util.decrypt(result, "czxms520"); Log.v(TAG, "result decrypted :" + result); JSONObject jo = new JSONObject(result); String code = jo.getString("code"); String msg = getJSONValueAsString(jo, "message"); if (code.equals("0")) { jo = new JSONObject(jo.getString("data")); // String loginTime = getJSONValueAsString(jo, "LastLogin"); // String lastLoginTime = getJSONValueAsString(jo, "LastLogin"); // SESSIONKEY /* * String sessionKey = getJSONValueAsString( jo, * "sessionkey"); */ // String urlHead = getJSONValueAsString(jo, "PhotoUrl"); String photoUrl = getJSONValueAsString(jo, "PhotoUrl"); String phone = getJSONValueAsString(jo, "Mobile"); Boolean vip = false; if (String.valueOf(jo.getInt("Vip")).equals("1")) { vip = true; } else { vip = false; } Env.isLogined = BaseActivity.isLogined = true; Log.v(TAG, ":1"); activity.markLogin(phone, phone, password, autoLogin, "", loginTime, lastLoginTime, vip); if (!photoUrl.equals("")) { String finalHeadUrl = URLDecoder.decode(photoUrl, "utf-8"); BaseActivity.setUserHeadUrl(finalHeadUrl); BaseActivity.setUserHeadDrawable(null); } else { BaseActivity.setUserHeadUrl(""); BaseActivity.setUserHeadDrawable(null); } // sendMsg(ConfigActivity.thiz,0); // start HomeActivity.now_mobile = phone; // end // // Log.v("", "kk" + phone); LoginActivity.instance.finish(); Util.saveFile(phone, Environment.getExternalStorageDirectory() + "/xmsphone.txt"); SharedPreferences.Editor sharedata = activity.getSharedPreferences("MyData", 0).edit(); sharedata.putString("isJZMM_czxms", "true"); sharedata.commit(); Log.i(TAG, ":2"); sendMsg(0); sendMsg(ConfigActivity.thiz, 2); activity.finish(); } else { Log.e(TAG, "server notify failed: error:" + msg); LoginActivity.pw.setText(""); activity.showMessageBox(msg); } } catch (JSONException e) { Log.e(TAG, "login error" + Log.getStackTraceString(e)); e.printStackTrace(); activity.showMessageBox(activity.getText(R.string.server404)); } catch (Exception e) { Log.e(TAG, Log.getStackTraceString(e)); //e.printStackTrace(); activity.showMessageBox(",."); } } @Override public void onFailureAnyway(int statusCode, Header[] headers, Throwable throwable, BaseBinaryResponse jsonResponse) { Log.i(TAG, "onFailureAnyway: " + statusCode); pd.dismiss(); activity.showMessageBox(activity.getText(R.string.server404)); } @Override public void onSuccessAnyway(int statusCode, Header[] headers, BaseBinaryResponse jsonResponse) { Log.i(TAG, "onSuccessAnyway: " + statusCode); } }); TimeCounter.countTime(activity, pd); }