Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. public class UpdateProfileAsync extends AsyncTask<Void, Void, Object> {
  2.  
  3. @Override
  4. protected void onPreExecute() {
  5. super.onPreExecute();
  6. showDialog();
  7. }
  8.  
  9. @Override
  10. protected Object doInBackground(Void... voids) {
  11. HashMap data = new HashMap();
  12. if (userData != null) {
  13. client = new LegitWampClient(userData.getUri(),
  14. userData.getRealm(), userData.getEmail(), userData.getPassword());
  15.  
  16. Map<String, Object> u = client.getLoginUser();
  17. if (u != null) {
  18. u.put(WampApiFieldKeys.U_FIRST, firstName);
  19. u.put(WampApiFieldKeys.U_LAST, lastName);
  20. //setup address object
  21. Map<String, Object> m = new HashMap<>();
  22. m.put(WampApiFieldKeys.UA_TYPE, "home");
  23. m.put(WampApiFieldKeys.UA_COUNTRY, "US");
  24. m.put(WampApiFieldKeys.UA_STATE, state);
  25. m.put(WampApiFieldKeys.UA_CITY, city);
  26.  
  27. // create new address list
  28. List<Map<String, Object>> nadds = new ArrayList<>();
  29. nadds.add(m);
  30.  
  31. // set address list to user object
  32. u.put(WampApiFieldKeys.U_ADDRESS_LIST, nadds);
  33. // u.put(WampApiFieldKeys.U_PROFILE_IMG, session.getProvaProfileImages());
  34. // u.put(WampApiFieldKeys.U_COVER_IMG, session.getProvaCoverImages());
  35. Map<String, Object> userObject = client.updateUser(u);
  36.  
  37.  
  38.  
  39.  
  40.  
  41. try {
  42. return userObject;
  43.  
  44. } catch (Exception ie) {
  45. new Thread() {
  46. public void run() {
  47. EditProfileActivity.this.runOnUiThread(new Runnable() {
  48. public void run() {
  49. noExecptionCaught = false;
  50. //Do your UI operations like dialog opening or Toast here
  51. ProvaUtile.showOrangeToast("Please try Again", EditProfileActivity.this, false);
  52. }
  53. });
  54. }
  55. }.start();
  56. }
  57. }
  58. }
  59. return null;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement