List of usage examples for android.os Message Message
public Message()
From source file:cn.xiaocool.android_etong.net.constant.request.MainRequest.java
public void bookingshopping(final String goodsid, final String peoplename, final String address, final String goodnum, final String mobile, final String remark, final String money, final String proid) { new Thread() { Message msg = new Message(); @Override//from w w w . j a va 2 s . c o m public void run() { Log.e("shopid is shop id", String.valueOf(user.getUserShopId())); String data = "&userid=" + user.getUserId() + "&shopid=" + user.getshopId() + "&goodsid=" + goodsid + "&address=" + address + "&goodnum=" + goodnum + "&mobile=" + mobile + "&remark=" + remark + "&money=" + money + "&proid=" + proid + "&deliverytype=2&deliverymoney=0"; Log.e("data=", data); String result_data = NetUtil.getResponse(WebAddress.BOOKING_SHOPPING, data); Log.e("result_data=", result_data); try { JSONObject jsonObject = new JSONObject(result_data); msg.what = CommunalInterfaces.BOOKING_SHOPPING; msg.obj = jsonObject; } catch (JSONException e) { e.printStackTrace(); } finally { handler.sendMessage(msg); } } }.start(); }
From source file:cm.aptoide.pt.ManageRepos.java
private void validateRepo(final String originalUriString, final boolean editMode) { final ViewDisplayRepo originalRepo; LayoutInflater li = LayoutInflater.from(ctx); View view = li.inflate(R.layout.addrepo, null); final TextView sec_msg = (TextView) view.findViewById(R.id.sec_msg); final TextView sec_msg2 = (TextView) view.findViewById(R.id.sec_msg2); final EditText sec_user = (EditText) view.findViewById(R.id.sec_user); final EditText sec_pwd = (EditText) view.findViewById(R.id.sec_pwd); final EditText uri = (EditText) view.findViewById(R.id.edit_uri); final CheckBox sec = (CheckBox) view.findViewById(R.id.secure_chk); sec.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { sec_user.setEnabled(true); sec_pwd.setEnabled(true); } else { sec_user.setEnabled(false); sec_pwd.setEnabled(false); }//w ww. ja va 2 s . c o m } }); Builder p = new AlertDialog.Builder(theme).setView(view); alrt = p.create(); CharSequence actionButtonString; if (editMode) { originalRepo = repos.getRepo(originalUriString.hashCode()); if (originalRepo.requiresLogin()) { sec.setChecked(true); sec_user.setText(originalRepo.getLogin().getUsername()); sec_pwd.setText(originalRepo.getLogin().getPassword()); } else { sec.setChecked(false); } alrt.setIcon(R.drawable.ic_menu_edit); alrt.setTitle(getText(R.string.edit_repo)); actionButtonString = getText(R.string.edit); } else { originalRepo = null; sec.setChecked(false); alrt.setIcon(R.drawable.ic_menu_add); alrt.setTitle(getText(R.string.add_repo)); actionButtonString = getText(R.string.add); } alrt.setButton(actionButtonString, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String uriString = uri.getText().toString(); String user = null; String pwd = null; if (sec.isChecked()) { user = sec_user.getText().toString(); pwd = sec_pwd.getText().toString(); } Message msg = new Message(); uriString = uriCheck(uriString); sec_msg.setVisibility(View.GONE); sec_msg2.setVisibility(View.GONE); returnStatus result = checkServerConnection(uriString, user, pwd); switch (result) { case OK: Log.d("Aptoide-ManageRepo", "return ok"); msg.obj = 0; if (isRepoManaged(uriString) && ((originalRepo != null && originalRepo.requiresLogin()) ? (originalRepo.getLogin().getUsername().equals(user) && originalRepo.getLogin().getPassword().equals(pwd)) : true)) { Toast.makeText(ctx, "Repo " + uriString + " already exists.", 5000).show(); // finish(); } else { ViewRepository newRepo = new ViewRepository(uriString); if (isRepoManaged(uriString)) { if (user != null && pwd != null) { reposManager.removeLogin(newRepo.getHashid()); } else { newRepo.setLogin(new ViewLogin(user, pwd)); reposManager.updateLogin(newRepo); } } else { if (user != null && pwd != null) { newRepo.setLogin(new ViewLogin(user, pwd)); } if (originalUriString != null) { removeDisplayRepo(originalUriString.hashCode()); } addDisplayRepo(newRepo); refreshReposList(); } alrt.dismiss(); } break; case LOGIN_REQUIRED: Log.d("Aptoide-ManageRepo", "return login_required"); sec_msg2.setText(getText(R.string.login_required)); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; break; case BAD_LOGIN: Log.d("Aptoide-ManageRepo", "return bad_login"); sec_msg2.setText(getText(R.string.bad_login)); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; break; case FAIL: Log.d("Aptoide-ManageRepo", "return fail"); uriString = uriString.substring(0, uriString.length() - 1) + ".bazaarandroid.com/"; Log.d("Aptoide-ManageRepo", "repo uri: " + uriString); msg.obj = 1; break; default: Log.d("Aptoide-ManageRepo", "return exception"); uriString = uriString.substring(0, uriString.length() - 1) + ".bazaarandroid.com/"; Log.d("Aptoide-ManageRepo", "repo uri: " + uriString); msg.obj = 1; break; } if (result.equals(returnStatus.FAIL) || result.equals(returnStatus.EXCEPTION)) { returnStatus result2 = checkServerConnection(uriString, user, pwd); switch (result2) { case OK: Log.d("Aptoide-ManageRepo", "return ok"); msg.obj = 0; if (isRepoManaged(uriString) && ((originalRepo != null && originalRepo.requiresLogin()) ? (originalRepo.getLogin().getUsername().equals(user) && originalRepo.getLogin().getPassword().equals(pwd)) : true)) { Toast.makeText(ctx, "Repo " + uriString + " already exists.", 5000).show(); // finish(); } else { ViewRepository newRepo = new ViewRepository(uriString); if (isRepoManaged(uriString)) { if (user != null && pwd != null) { reposManager.removeLogin(newRepo.getHashid()); } else { newRepo.setLogin(new ViewLogin(user, pwd)); reposManager.updateLogin(newRepo); } } else { if (user != null && pwd != null) { newRepo.setLogin(new ViewLogin(user, pwd)); } if (originalUriString != null) { removeDisplayRepo(originalUriString.hashCode()); } addDisplayRepo(newRepo); refreshReposList(); } alrt.dismiss(); } break; case LOGIN_REQUIRED: Log.d("Aptoide-ManageRepo", "return login_required"); sec_msg2.setText(getText(R.string.login_required)); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; break; case BAD_LOGIN: Log.d("Aptoide-ManageRepo", "return bad_login"); sec_msg2.setText(getText(R.string.bad_login)); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; break; case FAIL: Log.d("Aptoide-ManageRepo", "return fail"); sec_msg.setText(getText(R.string.cant_connect)); sec_msg.setVisibility(View.VISIBLE); msg.obj = 1; break; default: Log.d("Aptoide-ManageRepo", "return exception"); msg.obj = 1; break; } } invalidRepo.sendMessage(msg); } }); alrt.setButton2(getText(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alrt.dismiss(); } }); alrt.show(); if (originalUriString != null) { uri.setText(originalUriString); } }
From source file:pt.aptoide.backupapps.ManageRepos.java
private void validateRepo(final String originalUriString, final boolean editMode) { final ViewDisplayRepo originalRepo; LayoutInflater li = LayoutInflater.from(ctx); View view = li.inflate(R.layout.addrepo, null); final TextView sec_msg = (TextView) view.findViewById(R.id.sec_msg); final TextView sec_msg2 = (TextView) view.findViewById(R.id.sec_msg2); final EditText sec_user = (EditText) view.findViewById(R.id.sec_user); final EditText sec_pwd = (EditText) view.findViewById(R.id.sec_pwd); final EditText uri = (EditText) view.findViewById(R.id.edit_uri); final CheckBox sec = (CheckBox) view.findViewById(R.id.secure_chk); sec.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { sec_user.setEnabled(true); sec_pwd.setEnabled(true); } else { sec_user.setEnabled(false); sec_pwd.setEnabled(false); }/*from ww w .j av a2 s.c o m*/ } }); Builder p = new AlertDialog.Builder(theme).setView(view); alrt = p.create(); CharSequence actionButtonString; if (editMode) { originalRepo = repos.getRepo(originalUriString.hashCode()); if (originalRepo.requiresLogin()) { sec.setChecked(true); sec_user.setText(originalRepo.getLogin().getUsername()); sec_pwd.setText(originalRepo.getLogin().getPassword()); } else { sec.setChecked(false); } alrt.setIcon(R.drawable.ic_menu_edit); alrt.setTitle(getText(R.string.edit_repo)); actionButtonString = getText(R.string.edit); } else { originalRepo = null; sec.setChecked(false); alrt.setIcon(R.drawable.ic_menu_add); alrt.setTitle(getText(R.string.add_repo)); actionButtonString = getText(R.string.add); } alrt.setButton(actionButtonString, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String uriString = uri.getText().toString(); String user = null; String pwd = null; if (sec.isChecked()) { user = sec_user.getText().toString(); pwd = sec_pwd.getText().toString(); } Message msg = new Message(); uriString = uriCheck(uriString); sec_msg.setVisibility(View.GONE); sec_msg2.setVisibility(View.GONE); returnStatus result = checkServerConnection(uriString, user, pwd); switch (result) { case OK: Log.d("Aptoide-ManageRepo", "return ok"); msg.obj = 0; if (isRepoManaged(uriString) && ((originalRepo != null && originalRepo.requiresLogin()) ? (originalRepo.getLogin().getUsername().equals(user) && originalRepo.getLogin().getPassword().equals(pwd)) : true)) { Toast.makeText(ctx, "Repo " + uriString + " already exists.", 5000).show(); // finish(); } else { ViewRepository newRepo = new ViewRepository(uriString); if (isRepoManaged(uriString)) { if (user != null && pwd != null) { reposManager.removeLogin(newRepo.getHashid()); } else { newRepo.setLogin(new ViewLogin(user, pwd)); reposManager.updateLogin(newRepo); } } else { if (user != null && pwd != null) { newRepo.setLogin(new ViewLogin(user, pwd)); } if (originalUriString != null) { removeDisplayRepo(originalUriString.hashCode()); } addDisplayRepo(newRepo); refreshReposList(); } alrt.dismiss(); } break; case LOGIN_REQUIRED: Log.d("Aptoide-ManageRepo", "return login_required"); sec_msg2.setText(getText(R.string.login_required)); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; break; case BAD_LOGIN: Log.d("Aptoide-ManageRepo", "return bad_login"); sec_msg2.setText(getText(R.string.check_login)); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; break; case FAIL: Log.d("Aptoide-ManageRepo", "return fail"); uriString = uriString.substring(0, uriString.length() - 1) + Constants.DOMAIN_APTOIDE_STORE; Log.d("Aptoide-ManageRepo", "repo uri: " + uriString); msg.obj = 1; break; default: Log.d("Aptoide-ManageRepo", "return exception"); uriString = uriString.substring(0, uriString.length() - 1) + Constants.DOMAIN_APTOIDE_STORE; Log.d("Aptoide-ManageRepo", "repo uri: " + uriString); msg.obj = 1; break; } if (result.equals(returnStatus.FAIL) || result.equals(returnStatus.EXCEPTION)) { returnStatus result2 = checkServerConnection(uriString, user, pwd); switch (result2) { case OK: Log.d("Aptoide-ManageRepo", "return ok"); msg.obj = 0; if (isRepoManaged(uriString) && ((originalRepo != null && originalRepo.requiresLogin()) ? (originalRepo.getLogin().getUsername().equals(user) && originalRepo.getLogin().getPassword().equals(pwd)) : true)) { Toast.makeText(ctx, "Repo " + uriString + " already exists.", 5000).show(); // finish(); } else { ViewRepository newRepo = new ViewRepository(uriString); if (isRepoManaged(uriString)) { if (user != null && pwd != null) { reposManager.removeLogin(newRepo.getHashid()); } else { newRepo.setLogin(new ViewLogin(user, pwd)); reposManager.updateLogin(newRepo); } } else { if (user != null && pwd != null) { newRepo.setLogin(new ViewLogin(user, pwd)); } if (originalUriString != null) { removeDisplayRepo(originalUriString.hashCode()); } addDisplayRepo(newRepo); refreshReposList(); } alrt.dismiss(); } break; case LOGIN_REQUIRED: Log.d("Aptoide-ManageRepo", "return login_required"); sec_msg2.setText(getText(R.string.login_required)); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; break; case BAD_LOGIN: Log.d("Aptoide-ManageRepo", "return bad_login"); sec_msg2.setText(getText(R.string.check_login)); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; break; case FAIL: Log.d("Aptoide-ManageRepo", "return fail"); sec_msg.setText(getText(R.string.cant_connect)); sec_msg.setVisibility(View.VISIBLE); msg.obj = 1; break; default: Log.d("Aptoide-ManageRepo", "return exception"); msg.obj = 1; break; } } invalidRepo.sendMessage(msg); } }); alrt.setButton2(getText(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alrt.dismiss(); } }); alrt.show(); if (originalUriString != null) { uri.setText(originalUriString); } }
From source file:net.evecom.android.PublicOpinionLookActivity.java
/** * /*from w w w . ja va 2s .com*/ */ private void fileSubmitAfterForm(String table_id) { msg_listData2 = new Message(); if (fileListg.size() == 0) { if (null != progressDialog) { progressDialog.dismiss(); // } return; } for (int i = 0; i < fileListg.size(); i++) { if (i == fileListg.size() - 1) { isprogressDialogCanClose = true; } AjaxParams params = new AjaxParams(); try { params.put("profile_picture", new File(fileListg.get(i).getFile_URL())); params.put("uatable_id", table_id); } catch (FileNotFoundException e) { if (null != e) { e.printStackTrace(); } } // FinalHttp fh = new FinalHttp(); String furl = HttpUtil.BASE_URL + "teventAndroid/uploadSocial"; fh.post(furl, params, new AjaxCallBack<String>() { @Override public void onLoading(long count, long current) { System.out.println(current + "/" + count); } @Override public void onFailure(Throwable t, int errorNo, String strMsg) { msg_listData2.what = MESSAGETYPE_02; handler4.sendMessage(msg_listData2); super.onFailure(t, errorNo, strMsg); Toast.makeText(getApplicationContext(), "", 0).show(); } @Override public void onSuccess(String t) { super.onSuccess(t); toast("" + t); if (isprogressDialogCanClose) { msg_listData2.what = MESSAGETYPE_01; handler4.sendMessage(msg_listData2); } } }); } }
From source file:cn.xiaocool.android_etong.net.constant.request.MainRequest.java
public void getshoppingorderlist(final String state, final String deliverytype) { new Thread() { Message msg = new Message(); @Override/* ww w . ja v a 2 s . c o m*/ public void run() { String data = "&userid=" + user.getUserId() + state + deliverytype; Log.e("data=", data); String result_data = NetUtil.getResponse(WebAddress.GETSHOPPINGORDERLIST, data); Log.e("result_data=", result_data); try { JSONObject jsonObject = new JSONObject(result_data); msg.what = CommunalInterfaces.GET_SHOPPING_ORDER_LIST; msg.obj = jsonObject; } catch (JSONException e) { e.printStackTrace(); } finally { handler.sendMessage(msg); } } }.start(); }
From source file:com.ubiLive.GameCloud.Browser.WebBrowser.java
/** * JavaScript callBack method// ww w .java 2s . co m * @param parameter A JSON String, eg:{"request": {"code": "901","displayText": * "Your game ticket will be expired in 10 minutes"}} * * code -> 901 Your game ticket will be expired in 10 minutes * code -> 902 Your game ticket is expired */ private void announceMessage(final String parameter) { ((Activity) mContext).runOnUiThread(new Runnable() { @Override public void run() { try { JSONObject json; String code, displayText; json = new JSONObject(parameter); code = json.optString("code"); displayText = json.optString("displayText"); String presentMode = json.optString("presentMode"); if ("".equals(code) || code == null) { return; } Message msg = new Message(); msg.obj = displayText; DebugLog.d(TAG, "announceMessage code = " + code); if (presentMode != null) { if (presentMode.equals("twinkle")) { msg.arg1 = ANNOUNCEMESSAGE_PRESENTMODE_TWINKLE; } else { msg.arg1 = ANNOUNCEMESSAGE_PRESENTMODE_DIALOG; } } if (Constants.RESPONSE_901.equals(code)) { msg.what = HANDLE_RECEIVE_ANNOUNCE_901; if (mHandler != null) mHandler.sendMessage(msg); } else if (Constants.RESPONSE_902.equals(code)) { DebugLog.d(TAG, "announceMessage RESPONSE_902"); msg.what = HANDLE_RECEIVE_ANNOUNCE_902; if (mHandler != null) mHandler.sendMessage(msg); } else { if (Constants.RESPONSE_700.equals(code)) { msg.arg2 = 700; } else if (Constants.RESPONSE_710.equals(code)) { msg.arg2 = 710; } msg.what = HANDLE_RECEIVE_ANNOUNCE_700_710_1001; if (mHandler != null) mHandler.sendMessage(msg); } } catch (Exception e) { DebugLog.d(TAG, "exception = " + e.getMessage()); } } }); }
From source file:cn.xiaocool.android_etong.net.constant.request.MainRequest.java
public void GetShopList(final String city, final String type) { new Thread() { Message msg = new Message(); @Override// ww w.ja va 2 s.com public void run() { String data = "&city=" + city + "&type=" + type; Log.e("data=", data); String result_data = NetUtil.getResponse(WebAddress.GET_SHOP_LIST, data); Log.e("result_data=", result_data); try { JSONObject jsonObject = new JSONObject(result_data); msg.what = CommunalInterfaces.GET_SHOP_LIST; msg.obj = jsonObject; } catch (JSONException e) { e.printStackTrace(); } finally { handler.sendMessage(msg); } } }.start(); }
From source file:com.nbplus.vbroadlauncher.fragment.LauncherFragment.java
@Override public boolean onPushReceived(Message message) { Message msg = new Message(); msg.what = message.what;//from w w w .ja v a 2s.c om msg.arg1 = message.arg1; msg.arg2 = message.arg2; msg.obj = message.obj; mHandler.sendMessage(msg); return true; }
From source file:com.BeatYourRecord.SubmitActivity.java
public void asyncUpload(final Uri uri, final Handler handler) { new Thread(new Runnable() { @Override//from w w w . j av a2 s.c o m public void run() { Message msg = new Message(); Bundle bundle = new Bundle(); msg.setData(bundle); String videoId = null; int submitCount = 0; try { while (submitCount <= MAX_RETRIES && videoId == null) { try { submitCount++; videoId = startUpload(uri); //log.v("please",videoId); assert videoId != null; } catch (Internal500ResumeException e500) { // TODO - this should not really happen if (submitCount < MAX_RETRIES) { Log.w(LOG_TAG, e500.getMessage()); Log.d(LOG_TAG, String.format("Upload retry :%d.", submitCount)); } else { Log.d(LOG_TAG, "Giving up"); Log.e(LOG_TAG, e500.getMessage()); throw new IOException(e500.getMessage()); } } } } catch (IOException e) { e.printStackTrace(); bundle.putString("error", e.getMessage()); handler.sendMessage(msg); return; } catch (YouTubeAccountException e) { e.printStackTrace(); bundle.putString("error", e.getMessage()); handler.sendMessage(msg); return; } catch (SAXException e) { e.printStackTrace(); bundle.putString("error", e.getMessage()); handler.sendMessage(msg); } catch (ParserConfigurationException e) { e.printStackTrace(); bundle.putString("error", e.getMessage()); handler.sendMessage(msg); } bundle.putString("videoId", videoId); handler.sendMessage(msg); } }).start(); }
From source file:com.provision.alarmemi.paper.fragments.SetAlarmFragment.java
static void showToast(String result, boolean dismiss) { if (dismiss) { FragmentChangeActivity.progressDialog.dismiss(); }/* w w w . j a v a2 s . c om*/ Message m = new Message(); m.obj = result; toastHandler.sendMessage(m); }