in java/app/app/src/main/java/com/example/app/API/Rest/APIInfo.java [48:83]
public void getPersonalInfo(Context appContext, String userToken, UserInfoRunInterface userInfoRunInterface) {
RequestQueue queue = Volley.newRequestQueue(appContext);
String url = APIConstants.getAPIPersonalInfo();
JSONObject obj = new JSONObject();
JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.GET, url, obj,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
User u = User.parseUser(response);
// We call method run from the interface.
// This function is then implemented in the fragment when this method is called.
userInfoRunInterface.run(u);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("ExampleAPP", error.toString());
}
}
) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("Authorization", userToken);
return params;
}
};
queue.add(jsObjRequest);
}