List of usage examples for android.app ProgressDialog ProgressDialog
public ProgressDialog(Context context)
From source file:fm.smart.r1.activity.CreateItemActivity.java
public void onClick(View v) { EditText cueInput = (EditText) findViewById(R.id.cue); EditText responseInput = (EditText) findViewById(R.id.response); Spinner posInput = (Spinner) findViewById(R.id.pos); EditText characterResponseInput = (EditText) findViewById(R.id.response_character); EditText characterCueInput = (EditText) findViewById(R.id.cue_character); final String cue = cueInput.getText().toString(); final String response = responseInput.getText().toString(); final String pos = posInput.getSelectedItem().toString(); final String character_cue = characterCueInput.getText().toString(); final String character_response = characterResponseInput.getText().toString(); String pos_code = Utils.POS_MAP.get(pos); if (TextUtils.isEmpty(pos_code)) { pos_code = "NONE"; }/*from w w w. j a va2s. c o m*/ final String final_pos_code = pos_code; if (Main.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 = CreateItemActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("list_id", list_id); LoginActivity.params.put("cue", cue); LoginActivity.params.put("response", response); LoginActivity.params.put("cue_language", cue_language); LoginActivity.params.put("response_language", response_language); LoginActivity.params.put("pos", pos); LoginActivity.params.put("character_cue", character_cue); LoginActivity.params.put("character_response", character_response); startActivity(intent); } else { // TODO cue and response languages need to be inferred from list we are // adding to ... Might want to fix those, i.e. not allow variation // on // search ... // TODO wondering whether there is some way to edit existing items // ... final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Creating Item ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread create_item = new Thread() { public void run() { // TODO make this interruptable .../*if // (!this.isInterrupted())*/ CreateItemActivity.create_item_result = createItem(cue, cue_language, character_cue, final_pos_code, response, response_language, character_response, list_id); myOtherProgressDialog.dismiss(); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { create_item.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { create_item.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); myOtherProgressDialog.show(); create_item.start(); } }
From source file:com.shafiq.myfeedle.core.OAuthLogin.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setResult(RESULT_CANCELED);//from w w w.j ava2 s.c om mHttpClient = MyfeedleHttpClient.getThreadSafeClient(getApplicationContext()); mLoadingDialog = new ProgressDialog(this); mLoadingDialog.setMessage(getString(R.string.loading)); mLoadingDialog.setCancelable(true); mLoadingDialog.setOnCancelListener(this); mLoadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), this); Intent intent = getIntent(); if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { int service = extras.getInt(Myfeedle.Accounts.SERVICE, Myfeedle.INVALID_SERVICE); mServiceName = Myfeedle.getServiceName(getResources(), service); mWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); mAccountId = extras.getLong(Myfeedle.EXTRA_ACCOUNT_ID, Myfeedle.INVALID_ACCOUNT_ID); mMyfeedleWebView = new MyfeedleWebView(); final ProgressDialog loadingDialog = new ProgressDialog(this); final AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... args) { try { return mMyfeedleOAuth.getAuthUrl(args[0], args[1], args[2], args[3], Boolean.parseBoolean(args[4]), mHttpClient); } catch (OAuthMessageSignerException e) { e.printStackTrace(); } catch (OAuthNotAuthorizedException e) { e.printStackTrace(); } catch (OAuthExpectationFailedException e) { e.printStackTrace(); } catch (OAuthCommunicationException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(String url) { if (loadingDialog.isShowing()) loadingDialog.dismiss(); // load the webview if (url != null) { mMyfeedleWebView.open(url); } else { (Toast.makeText(OAuthLogin.this, String.format(getString(R.string.oauth_error), mServiceName), Toast.LENGTH_LONG)).show(); OAuthLogin.this.finish(); } } }; loadingDialog.setMessage(getString(R.string.loading)); loadingDialog.setCancelable(true); loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); dialog.cancel(); OAuthLogin.this.finish(); } }); loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); dialog.cancel(); OAuthLogin.this.finish(); } }); switch (service) { case TWITTER: mMyfeedleOAuth = new MyfeedleOAuth(TWITTER_KEY, TWITTER_SECRET); asyncTask.execute(String.format(TWITTER_URL_REQUEST, TWITTER_BASE_URL), String.format(TWITTER_URL_ACCESS, TWITTER_BASE_URL), String.format(TWITTER_URL_AUTHORIZE, TWITTER_BASE_URL), TWITTER_CALLBACK.toString(), Boolean.toString(true)); loadingDialog.show(); break; case FACEBOOK: mMyfeedleWebView.open(String.format(FACEBOOK_URL_AUTHORIZE, FACEBOOK_BASE_URL, FACEBOOK_ID, FACEBOOK_CALLBACK.toString())); break; // case MYSPACE: // mMyfeedleOAuth = new MyfeedleOAuth(MYSPACE_KEY, MYSPACE_SECRET); // asyncTask.execute(MYSPACE_URL_REQUEST, MYSPACE_URL_ACCESS, MYSPACE_URL_AUTHORIZE, MYSPACE_CALLBACK.toString(), Boolean.toString(true)); // loadingDialog.show(); // break; case FOURSQUARE: mMyfeedleWebView.open(String.format(FOURSQUARE_URL_AUTHORIZE, FOURSQUARE_KEY, FOURSQUARE_CALLBACK.toString())); break; case LINKEDIN: mMyfeedleOAuth = new MyfeedleOAuth(LINKEDIN_KEY, LINKEDIN_SECRET); asyncTask.execute(LINKEDIN_URL_REQUEST, LINKEDIN_URL_ACCESS, LINKEDIN_URL_AUTHORIZE, LINKEDIN_CALLBACK.toString(), Boolean.toString(true)); loadingDialog.show(); break; case SMS: Cursor c = getContentResolver().query(Accounts.getContentUri(this), new String[] { Accounts._ID }, Accounts.SERVICE + "=?", new String[] { Integer.toString(SMS) }, null); if (c.moveToFirst()) { (Toast.makeText(OAuthLogin.this, "SMS has already been added.", Toast.LENGTH_LONG)).show(); } else { addAccount(getResources().getStringArray(R.array.service_entries)[SMS], null, null, 0, SMS, null); } c.close(); finish(); break; case RSS: // prompt for RSS url final EditText rss_url = new EditText(this); rss_url.setSingleLine(); new AlertDialog.Builder(OAuthLogin.this).setTitle(R.string.rss_url).setView(rss_url) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { // test the url and add if valid, else Toast error mLoadingDialog.show(); (new AsyncTask<String, Void, String>() { String url; @Override protected String doInBackground(String... params) { url = rss_url.getText().toString(); return MyfeedleHttpClient.httpResponse(mHttpClient, new HttpGet(url)); } @Override protected void onPostExecute(String response) { mLoadingDialog.dismiss(); if (response != null) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db; try { db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(response)); Document doc = db.parse(is); // test parsing... NodeList nodes = doc.getElementsByTagName(Sitem); if (nodes.getLength() > 0) { // check for an image NodeList images = doc.getElementsByTagName(Simage); if (images.getLength() > 0) { NodeList imageChildren = images.item(0).getChildNodes(); Node n = imageChildren.item(0); if (n.getNodeName().toLowerCase().equals(Surl)) { if (n.hasChildNodes()) { n.getChildNodes().item(0).getNodeValue(); } } } NodeList children = nodes.item(0).getChildNodes(); String date = null; String title = null; String description = null; String link = null; int values_count = 0; for (int child = 0, c2 = children.getLength(); (child < c2) && (values_count < 4); child++) { Node n = children.item(child); if (n.getNodeName().toLowerCase().equals(Spubdate)) { values_count++; if (n.hasChildNodes()) { date = n.getChildNodes().item(0).getNodeValue(); } } else if (n.getNodeName().toLowerCase() .equals(Stitle)) { values_count++; if (n.hasChildNodes()) { title = n.getChildNodes().item(0) .getNodeValue(); } } else if (n.getNodeName().toLowerCase() .equals(Sdescription)) { values_count++; if (n.hasChildNodes()) { StringBuilder sb = new StringBuilder(); NodeList descNodes = n.getChildNodes(); for (int dn = 0, dn2 = descNodes .getLength(); dn < dn2; dn++) { Node descNode = descNodes.item(dn); if (descNode .getNodeType() == Node.TEXT_NODE) { sb.append(descNode.getNodeValue()); } } // strip out the html tags description = sb.toString() .replaceAll("\\<(.|\n)*?>", ""); } } else if (n.getNodeName().toLowerCase() .equals(Slink)) { values_count++; if (n.hasChildNodes()) { link = n.getChildNodes().item(0).getNodeValue(); } } } if (Myfeedle.HasValues( new String[] { title, description, link, date })) { final EditText url_name = new EditText(OAuthLogin.this); url_name.setSingleLine(); new AlertDialog.Builder(OAuthLogin.this) .setTitle(R.string.rss_channel) .setView(url_name) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick( DialogInterface dialog1, int which) { addAccount( url_name.getText() .toString(), null, null, 0, RSS, url); dialog1.dismiss(); dialog.dismiss(); finish(); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick( DialogInterface dialog1, int which) { dialog1.dismiss(); dialog.dismiss(); finish(); } }) .show(); } else { (Toast.makeText(OAuthLogin.this, "Feed is missing standard fields", Toast.LENGTH_LONG)).show(); } } else { (Toast.makeText(OAuthLogin.this, "Invalid feed", Toast.LENGTH_LONG)).show(); dialog.dismiss(); finish(); } } catch (ParserConfigurationException e) { Log.e(TAG, e.toString()); (Toast.makeText(OAuthLogin.this, "Invalid feed", Toast.LENGTH_LONG)).show(); dialog.dismiss(); finish(); } catch (SAXException e) { Log.e(TAG, e.toString()); (Toast.makeText(OAuthLogin.this, "Invalid feed", Toast.LENGTH_LONG)).show(); dialog.dismiss(); finish(); } catch (IOException e) { Log.e(TAG, e.toString()); (Toast.makeText(OAuthLogin.this, "Invalid feed", Toast.LENGTH_LONG)).show(); dialog.dismiss(); finish(); } } else { (Toast.makeText(OAuthLogin.this, "Invalid URL", Toast.LENGTH_LONG)) .show(); dialog.dismiss(); finish(); } } }).execute(rss_url.getText().toString()); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }).show(); break; // case IDENTICA: // mMyfeedleOAuth = new MyfeedleOAuth(IDENTICA_KEY, IDENTICA_SECRET); // asyncTask.execute(String.format(IDENTICA_URL_REQUEST, IDENTICA_BASE_URL), String.format(IDENTICA_URL_ACCESS, IDENTICA_BASE_URL), String.format(IDENTICA_URL_AUTHORIZE, IDENTICA_BASE_URL), IDENTICA_CALLBACK.toString(), Boolean.toString(true)); // loadingDialog.show(); // break; case GOOGLEPLUS: mMyfeedleWebView.open( String.format(GOOGLEPLUS_AUTHORIZE, GOOGLE_CLIENTID, "urn:ietf:wg:oauth:2.0:oob")); break; // case CHATTER: // mMyfeedleWebView.open(String.format(CHATTER_URL_AUTHORIZE, CHATTER_KEY, CHATTER_CALLBACK.toString())); // break; case PINTEREST: Cursor pinterestAccount = getContentResolver().query(Accounts.getContentUri(this), new String[] { Accounts._ID }, Accounts.SERVICE + "=?", new String[] { Integer.toString(PINTEREST) }, null); if (pinterestAccount.moveToFirst()) { (Toast.makeText(OAuthLogin.this, "Pinterest has already been added.", Toast.LENGTH_LONG)) .show(); } else { (Toast.makeText(OAuthLogin.this, "Pinterest currently allows only public, non-authenticated viewing.", Toast.LENGTH_LONG)).show(); String[] values = getResources().getStringArray(R.array.service_values); String[] entries = getResources().getStringArray(R.array.service_entries); for (int i = 0, l = values.length; i < l; i++) { if (Integer.toString(PINTEREST).equals(values[i])) { addAccount(entries[i], null, null, 0, PINTEREST, null); break; } } } pinterestAccount.close(); finish(); break; default: this.finish(); } } } }
From source file:com.paramedic.mobshaman.fragments.AccionesDetalleServicioFragment.java
private void initializeUI(View myView) { finishRequestParams = new RequestParams(); btnLlegadaServicio = (Button) myView.findViewById(R.id.btn_llegada_servicio); btnSalidaServicio = (Button) myView.findViewById(R.id.btn_salida_servicio); btnFinalServicio = (Button) myView.findViewById(R.id.btn_final_servicio); btnHistoriaClinica = (Button) myView.findViewById(R.id.btn_hc_paciente_servicio); btnCancelarServicio = (Button) myView.findViewById(R.id.btn_cancelacion_servicio); btnDistanciaServicio = (Button) myView.findViewById(R.id.btn_distancia_servicio); btnAttachImage = (Button) myView.findViewById(R.id.btn_attach_image); if (serv.getFlgRename() == 1) { btnSalidaServicio.setText("Derivacin"); btnLlegadaServicio.setText("Internacin"); }/*from w w w .j av a 2 s . c o m*/ toggleButton(btnLlegadaServicio, serv.getHabLlegada()); toggleButton(btnSalidaServicio, serv.getHabSalida()); toggleButton(btnFinalServicio, serv.getHabFinal()); toggleButton(btnCancelarServicio, serv.getHabCancelacion()); pDialog = new ProgressDialog(getActivity()); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); }
From source file:com.imalu.alyou.activity.RegisterActivity.java
/** * //from w w w . ja v a 2 s . c o m * * @param view */ public void register(View view) { final String pwd = passwordEditText.getText().toString().trim(); String confirm_pwd = confirmPwdEditText.getText().toString().trim(); if (TextUtils.isEmpty(pwd)) { Toast.makeText(this, "???", Toast.LENGTH_SHORT).show(); passwordEditText.requestFocus(); return; } else if (TextUtils.isEmpty(confirm_pwd)) { Toast.makeText(this, "???", Toast.LENGTH_SHORT).show(); confirmPwdEditText.requestFocus(); return; } else if (!pwd.equals(confirm_pwd)) { Toast.makeText(this, "????", Toast.LENGTH_SHORT).show(); return; } RegisterRequest registerReq = new RegisterRequest(); registerReq.setPassword(pwd); registerReq.setUsername(username); NetManager.execute(NetManager.REGISTER_REQUEST_OPERATION, registerReq, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { //pd.dismiss(); Log.e("login_check", " response:" + response.toString()); //Toast.makeText(getApplicationContext(), ": " + , 0).show(); //RegisterResponse regResp = (RegisterResponse)response; // ????? //AlUApplication.getInstance().setUserName(username); //AlUApplication.getInstance().setPassword(password); /*runOnUiThread(new Runnable() { public void run() { pd.setMessage("???..."); } });*/ try { RegisterResponse regResp = new RegisterResponse(); regResp.setJsonObject(response); Log.e("AAAAAAAAAA", "" + regResp.getCode()); if (regResp.getCode()) { Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), ": " + regResp.getInfo(), Toast.LENGTH_SHORT).show(); } // ** ?logout?? // ** manually load all local groups and // conversations in case we are auto login //EMGroupManager.getInstance().loadAllGroups(); //EMChatManager.getInstance().loadAllConversations(); // demo??????username?? /*List<String> usernames = EMContactManager.getInstance().getContactUserNames(); EMLog.d("roster", "contacts size: " + usernames.size()); for (String username : usernames) { User user = new User(); user.setUsername(username); setUserHearder(username, user); userlist.put(username, user); }*/ /*Map<String, User> userlist = new HashMap<String, User>(); // user"" User newFriends = new User(); newFriends.setUsername(Constant.NEW_FRIENDS_USERNAME); newFriends.setNick(""); newFriends.setHeader(""); userlist.put(Constant.NEW_FRIENDS_USERNAME, newFriends); // "?" User groupUser = new User(); groupUser.setUsername(Constant.GROUP_USERNAME); groupUser.setNick("?"); groupUser.setHeader(""); userlist.put(Constant.GROUP_USERNAME, groupUser);*/ // //AlUApplication.getInstance().setContactList(userlist); // db //UserDao dao = new UserDao(LoginActivity.this); //List<User> users = new ArrayList<User>(userlist.values()); //dao.saveContactList(users); // ??(??groupidgroupname????members),sdkdb //EMGroupManager.getInstance().getGroupsFromServer();*/ } catch (Exception e) { Toast.makeText(getApplicationContext(), ": " + e.getMessage(), Toast.LENGTH_SHORT) .show(); //e.printStackTrace(); } Log.e("login_check", "1111111111111111111"); //?nickname ios?nick //boolean updatenick = EMChatManager.getInstance().updateCurrentUserNick(AlUApplication.currentUserNick); //if (!updatenick) { // EMLog.e("LoginActivity", "update current user nick fail"); //} //if (!LoginActivity.this.isFinishing()) //pd.dismiss(); // ? startActivity(new Intent(RegisterActivity.this, LoginActivity.class)); finish(); } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject jsonObj) { // Log.e("register", throwable.getMessage()); finish(); } @Override public void onFailure(int statusCode, Header[] headers, final String responseString, Throwable throwable) { runOnUiThread(new Runnable() { public void run() { //pd.dismiss(); //Toast.makeText(getApplicationContext(), ": " + responseString, 0).show(); Log.e("register", responseString); finish(); } }); } }); // if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) { final ProgressDialog pd = new ProgressDialog(this); pd.setMessage("..."); pd.show(); new Thread(new Runnable() { public void run() { try { // sdk EMChatManager.getInstance().createAccountOnServer(username, pwd); runOnUiThread(new Runnable() { public void run() { if (!RegisterActivity.this.isFinishing()) pd.dismiss(); // ??? AlUApplication.getInstance().setUserName(username); Toast.makeText(getApplicationContext(), "?", 0).show(); finish(); } }); } catch (final EaseMobException e) { runOnUiThread(new Runnable() { public void run() { if (!RegisterActivity.this.isFinishing()) pd.dismiss(); int errorCode = e.getErrorCode(); if (errorCode == EMError.NONETWORK_ERROR) { Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT).show(); } else if (errorCode == EMError.USER_ALREADY_EXISTS) { Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT).show(); } else if (errorCode == EMError.UNAUTHORIZED) { Toast.makeText(getApplicationContext(), "???", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), ": " + e.getMessage(), Toast.LENGTH_SHORT).show(); } } }); } } }).start(); } // }
From source file:com.huison.DriverAssistant_Web.util.LoginHelper.java
public static void register(final BaseActivity activity, final String username, final String phone, final String password, final String tjrphone, final String yzm) { UmengEventSender.sendEvent(activity, UmengEventTypes.register); final ProgressDialog pd = new ProgressDialog(activity); pd.setMessage("..."); pd.setCanceledOnTouchOutside(false); pd.setCancelable(false);/* ww w. j a v a2 s . c om*/ pd.show(); /* * Map<String, String> map = new HashMap<String, String>(); * map.put("sessionkey", BaseActivity.getSESSIONKEY()); * map.put("userid", username); map.put("mob", phone); * map.put("passwork", password); map.put("version", * activity.getVersionName()); map.put("imei", * DeviceUniqueIdentifier.getIMEIorMEID(activity)); map.put("imsi", * DeviceUniqueIdentifier.getIMSI(activity)); map.put("mac", * DeviceUniqueIdentifier.getMacAddress(activity)); map.put("channel", * getChannel(activity)); map.put("referee", tjrphone); map.put("Lng", ; * map.put("Lat", HomeActivity.gps_jdHomeActivity.gps_wd)); * map.put("Code", yzm); */ AsyncHttpClient client = activity.getAsyncHttpClient(); RequestParams params = new RequestParams(); /* * params.put("action", REGISTER_ACTION); params.put("xml", * BaseActivity.getXML(map)); */ try { JSONObject p = new JSONObject(); p.put("mobile", phone); p.put("password", password); p.put("method", "register"); p.put("version", activity.getVersionName()); p.put("devicetype", "android"); p.put("channel", getChannel(activity)); p.put("imei", DeviceUniqueIdentifier.getIMEIorMEID(activity)); p.put("imsi", "android" + DeviceUniqueIdentifier.getIMSI(activity)); p.put("lat", Env.latitude); p.put("lng", Env.longitude); p.put("mac", DeviceUniqueIdentifier.getMacAddress(activity)); p.put("referee", tjrphone); p.put("username", username); p.put("code", yzm); 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("JSON", p.toString()); String data = Util.DesJiaMi(p.toString(), "czxms520"); 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) { Log.v("", "1"); pd.dismiss(); try { result = Util.decrypt(result, "czxms520"); Log.v("JSON", result); JSONObject jo = new JSONObject(result); String code = jo.getString("code"); /* * boolean registerFlag = getJSONValueAsString(jo, "code") * .equals("0"); */ String msg = getJSONValueAsString(jo, "message"); if (code.equals("0")) { String data = jo.getString("data"); jo = new JSONObject(data); /* * registerFlag = getJSONValueAsString(jo, "logincode") * .equals("0"); */ // msg = getJSONValueAsString(jo, "loginmessage"); /* * String passwordMD5 = getJSONValueAsString( jo, * "pass"); */ /* * // String breakRuleRemind = * getJSONValueAsString( jo, "wzxx"); // String * changeLicenseRemind = getJSONValueAsString( jo, * "hzxx"); // String examineRemind = * getJSONValueAsString(jo, "nsxx"); */ // vip /* * boolean isVip = getJSONValueAsString(jo, "Vip") * .equals("true"); // String * blackPointUpdateTime = getJSONValueAsString( jo, * "wzhdtime"); // String toolUpdateTime = * getJSONValueAsString( jo, "sygjtime"); // * String favorUpdateTime = getJSONValueAsString( jo, * "yhtime"); */ /* * boolean isVip = getJSONValueAsString(jo, "Vip") * .equals("true"); */ // 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; } Log.v("VIP", String.valueOf(vip)); activity.markLogin(phone, phone, password, true, "", 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); } try { pd.dismiss(); } catch (Exception e) { e.printStackTrace(); } sendMsg(ConfigActivity.thiz, 0); activity.finish(); } else { activity.showMessageBox(msg); } } catch (JSONException e) { e.printStackTrace(); // activity.markLogout(); // sendMsg(activity,1); activity.showMessageBox(activity.getText(R.string.server404)); Log.e("register error", Log.getStackTraceString(e)); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); activity.showMessageBox(""); } } @Override public void onFailureAnyway(int statusCode, Header[] headers, Throwable throwable, BaseBinaryResponse jsonResponse) { Log.v("C", "1"); pd.dismiss(); activity.showMessageBox(activity.getText(R.string.server404)); } @Override public void onSuccessAnyway(int statusCode, Header[] headers, BaseBinaryResponse jsonResponse) { pd.dismiss(); Log.v("A", "1"); } }); Log.v("B", "1"); TimeCounter.countTime(activity, pd); }
From source file:com.example.run_tracker.RunFragment.java
private void save_track() { pDialog = new ProgressDialog(getActivity()); pDialog.setMessage("Saving track "); showProgressDialog();//from www . j a v a2s . c o m String line = PolyUtil.encode(((MainActivity) getActivity()).getMyService().getCoursePoints()); Calendar c = Calendar.getInstance(); String time = (String) mTimer.getTimer().getText(); String date = c.get(Calendar.DATE) + "-" + (1 + c.get(Calendar.MONTH)) + "-" + c.get(Calendar.YEAR); String distance = (String) mDistanceText.getText(); JSONObject new_run = new JSONObject(); try { new_run.put("track", line); new_run.put("date", date); new_run.put("distance", distance); new_run.put("time", time); } catch (JSONException e) { e.printStackTrace(); } JsonObjectRequest save_req = new JsonObjectRequest(Method.POST, URLS.URL_TRACKS, new_run, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { hideProgressDialog(); reset_fragment(); try { if (response.get("error") != null) { Toast.makeText(getActivity(), (CharSequence) response.get("error"), Toast.LENGTH_LONG).show(); } } catch (JSONException e) { Toast.makeText(getActivity(), "Track saved", Toast.LENGTH_LONG).show(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError arg0) { hideProgressDialog(); Toast.makeText(getActivity(), "Error", Toast.LENGTH_LONG).show(); } }) { /** * Passing some request headers token and content type * */ @Override public Map<String, String> getHeaders() throws AuthFailureError { HashMap<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/json"); headers.put("x-access-token", mToken); return headers; } }; AppController.getInstance().addToRequestQueue(save_req, TAG); }
From source file:edu.polyu.screamalert.SoundProcessing.java
@SuppressWarnings("unchecked") public static void initialize(Context context) { thisContext = context;/*from www .j a v a 2 s . c o m*/ x = new float[samplePerFrm]; subx = new float[frameShift]; // Samples in a sub-frame mfcc = new MFCC(samplePerFrm, Config.RECORDER_SAMPLERATE, numMfcc); ccBuf = new CircularFifoBuffer(K); // Buffer storing K mfcc vectors dccBuf = new CircularFifoBuffer(K); // Buffer storing K delta-mfcc vectors pDet = new YinPitchDetector(Config.RECORDER_SAMPLERATE, samplePerFrm); piBuf = new CircularFifoBuffer(K); pkBuf = new CircularFifoBuffer(K); mu_z = new double[] { VoiceQuality.JITTER_MEAN, VoiceQuality.SHIMMER_MEAN }; // Jitter and shimmer mean sigma_z = new double[] { VoiceQuality.JITTER_STD, VoiceQuality.SHIMMER_STD }; // Jitter and shimmer stddev aList = new ArrayList<double[]>(); enBuf = new CircularFifoBuffer(enBufSize); // Circular buffer storing energy profile of the latest K frames frmBuf = new CircularFifoBuffer(K); // Buffer storing K latest frames of audio signals */ for (int k = 0; k < K; k++) { ccBuf.add(new double[numMfcc + 1]); // Initialize MFCC FIFO buffers dccBuf.add(new double[numMfcc + 1]); // Initialize delta MFCC FIFO buffers piBuf.add(-1.0D); // Initialize pitch FIFO buffer for computing jitter and shimmer pkBuf.add(0.0D); // Initialize peak amplitude FIFO buffer for computing shimmer frmBuf.add(new double[samplePerFrm]); // Initialize frame buffer } for (int k = 0; k < enBufSize; k++) { enBuf.add(new double[1]); // Initialize energy buffer } mainIntent = new Intent(thisContext, SoundProcessingSetting.class); mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); pIntent = PendingIntent.getActivity(thisContext, 0, mainIntent, 0); // Go back to MainActivity when user press the notification noti = new NotificationCompat.Builder(thisContext) .setContentTitle( thisContext.getString(R.string.app_name) + " " + thisContext.getString(R.string.running)) .setContentText(thisContext.getString(R.string.configure)).setSmallIcon(R.drawable.ic_launcher) .setContentIntent(pIntent).build(); noti.flags = Notification.FLAG_FOREGROUND_SERVICE; if (SoundProcessingActivity.thisActivity == null) calibrateDialog = new ProgressDialog(Exchanger.thisContext); else calibrateDialog = new ProgressDialog(SoundProcessingActivity.thisActivity); }
From source file:nf.frex.android.FrexActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { return;//w ww.j a v a 2 s. c om } if (requestCode == R.id.manage_fractals && data.getAction().equals(Intent.ACTION_VIEW)) { final Uri imageUri = data.getData(); if (imageUri != null) { File imageFile = new File(imageUri.getPath()); String configName = FrexIO.getFilenameWithoutExt(imageFile); File paramFile = new File(imageFile.getParent(), configName + FrexIO.PARAM_FILE_EXT); try { FileInputStream fis = new FileInputStream(paramFile); try { readFrexDoc(fis, configName); } finally { fis.close(); } } catch (IOException e) { Toast.makeText(FrexActivity.this, getString(R.string.error_msg, e.getLocalizedMessage()), Toast.LENGTH_SHORT).show(); } } } else if (requestCode == R.id.settings) { view.getGenerator().setNumTasks(SettingsActivity.getNumTasks(this)); } else if (requestCode == SELECT_PICTURE_REQUEST_CODE) { final Uri imageUri = data.getData(); final ColorQuantizer colorQuantizer = new ColorQuantizer(); final ProgressDialog progressDialog = new ProgressDialog(FrexActivity.this); final DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } colorQuantizer.cancel(); } }; final ColorQuantizer.ProgressListener progressListener = new ColorQuantizer.ProgressListener() { @Override public void progress(final String msg, final int iter, final int maxIter) { runOnUiThread(new Runnable() { @Override public void run() { progressDialog.setMessage(msg); progressDialog.setProgress(iter); } }); } }; progressDialog.setTitle(getString(R.string.get_pal_from_img_title)); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setCancelable(true); progressDialog.setOnCancelListener(cancelListener); progressDialog.setMax(colorQuantizer.getMaxIterCount()); progressDialog.show(); Thread thread = new Thread(new Runnable() { @Override public void run() { Bitmap bitmap; try { bitmap = FrexIO.readBitmap(getContentResolver(), imageUri, 256); } catch (IOException e) { alert("I/O error: " + e.getLocalizedMessage()); return; } ColorScheme colorScheme = colorQuantizer.quantize(bitmap, progressListener); progressDialog.dismiss(); if (colorScheme != null) { Log.d(TAG, "SELECT_PICTURE_REQUEST_CODE: Got colorScheme"); String colorSchemeId = "$" + imageUri.toString(); colorSchemes.add(colorSchemeId, colorScheme); view.setColorSchemeId(colorSchemeId); view.setColorScheme(colorScheme); view.recomputeColors(); runOnUiThread(new Runnable() { @Override public void run() { Log.d(TAG, "SELECT_PICTURE_REQUEST_CODE: showDialog(R.id.colors)"); showDialog(R.id.colors); } }); } } }); thread.start(); } }
From source file:com.pansapiens.occyd.Search.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_SEARCHING: { ProgressDialog dialog = new ProgressDialog(this); dialog.setTitle("Searching ..."); dialog.setMessage("Searching ..."); dialog.setIndeterminate(true);/*from w w w . j av a2s . c o m*/ dialog.setCancelable(false); return dialog; } } return null; }