Created
January 25, 2017 12:33
-
-
Save sjehutch/18ef4ef33dc7f2f2f90b24d0b77c9a6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UpdateProfileAsync extends AsyncTask<Void, Void, Object> { | |
@Override | |
protected void onPreExecute() { | |
super.onPreExecute(); | |
showDialog(); | |
} | |
@Override | |
protected Object doInBackground(Void... voids) { | |
HashMap data = new HashMap(); | |
if (userData != null) { | |
client = new LegitWampClient(userData.getUri(), | |
userData.getRealm(), userData.getEmail(), userData.getPassword()); | |
Map<String, Object> u = client.getLoginUser(); | |
if (u != null) { | |
u.put(WampApiFieldKeys.U_FIRST, firstName); | |
u.put(WampApiFieldKeys.U_LAST, lastName); | |
//setup address object | |
Map<String, Object> m = new HashMap<>(); | |
m.put(WampApiFieldKeys.UA_TYPE, "home"); | |
m.put(WampApiFieldKeys.UA_COUNTRY, "US"); | |
m.put(WampApiFieldKeys.UA_STATE, state); | |
m.put(WampApiFieldKeys.UA_CITY, city); | |
// create new address list | |
List<Map<String, Object>> nadds = new ArrayList<>(); | |
nadds.add(m); | |
Map<String, Object> userObject = client.updateUser(u); | |
try { | |
return userObject; | |
} catch (Exception ie) { | |
new Thread() { | |
public void run() { | |
EditProfileActivity.this.runOnUiThread(new Runnable() { | |
public void run() { | |
noExecptionCaught = false; | |
//Do your UI operations like dialog opening or Toast here | |
ProvaUtile.showOrangeToast("Please try Again", EditProfileActivity.this, false); | |
} | |
}); | |
} | |
}.start(); | |
} | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment