Skip to content

Instantly share code, notes, and snippets.

@RajeshBatth
Last active October 8, 2015 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RajeshBatth/5453c51c8b3c88041591 to your computer and use it in GitHub Desktop.
Save RajeshBatth/5453c51c8b3c88041591 to your computer and use it in GitHub Desktop.
private void publishProfileDetails(){
final ProgressDialog updateProgress = ProgressDialog.show(this, "Updating Your Details", "Please Wait", false);
try{
JSONObject params = new JSONObject();
params.put("first_name",firstName.getText().toString());
params.put("last_name",lastName.getText().toString());
params.put("age",age.getText().toString());
if(maleBtn.isChecked())
params.put("gender","male");
else
params.put("gender","female");
JsonObjectRequest request = new JsonObjectRequest(
Request.Method.PUT,
String.format(ProjectURLs.USER_DETAILS, getUserID(Constants.PREFS_USER_ID)),
params,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject jsonObject) {
Log.d("oioLog", "updateUserProfile: " + jsonObject.toString());
Toast.makeText(UserProfile.this, "Your details updated successfully",Toast.LENGTH_SHORT).show();
tracker.sendEvent("ui_action", "UserProfile", "updated_user_details", 0L);
saveUserDetails();
try {
if(isConvertDrawableToFile()){
sendUserPic();
}
} catch (IOException e) {
e.printStackTrace();
}
updateProgress.dismiss();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Log.d("oioLog", "updateUserProfile: " + volleyError.toString());
Toast.makeText(UserProfile.this, "Could not update, try again",Toast.LENGTH_SHORT).show();
updateProgress.dismiss();
}
}
);
Volley.newRequestQueue(this).add(request);
}catch (JSONException e){
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment