Answer the question
In order to leave comments, you need to log in
Android. Volley. Why are some methods not being called?
There is this code:
public void loadMyInventory(final Map<String, String> options, final Callback callback) {
Log.d(TAG, "loadMyInventory: " + url);
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
callback.onResult(SteamItemRepository.fromJSONObject(response));
} catch (JSONException e) {
callback.onError(new Error("Ошибка чтения данных"));
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG, "onErrorResponse: " + error.networkResponse);
callback.onError(new Error(error));
}
}) {
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
Log.d(TAG, "parseNetworkResponse: " + new String(response.data));
return super.parseNetworkResponse(response);
}
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Log.d(TAG, "getParams: ");
Map<String, String> params = new HashMap<>();
params.put("l", "russian"); // Язык
params.put("trading", "1"); // Только для обмена
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Log.d(TAG, "getHeaders: ");
Map<String, String> headers = new HashMap<>();
headers.put("Cookie", mSteamCookie);
return headers;
}
};
mRequestQueue.add(request);
callback.onStart();
}
06-07 12:55:21.893 5843-5843/my.package D/Steam: loadMyInventory: https://steamcommunity.com/my/inventory/json/730/2/
06-07 12:55:21.903 5843-6161/my.package D/Steam: getHeaders:
06-07 12:55:23.635 5843-5843/my.package D/Steam: onErrorResponse: null
public class SteamJsonObjectRequest extends JsonObjectRequest {
public static final String TAG = "SteamJsonObjectRequest";
public SteamJsonObjectRequest(int method, String url, Response.Listener<JSONObject> listener, Response.ErrorListener errorListener) {
super(method, url, listener, errorListener);
Log.d(TAG, "SteamJsonObjectRequest: ");
}
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
Log.d(TAG, "parseNetworkResponse: " + new String(response.data));
return super.parseNetworkResponse(response);
}
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Log.d(TAG, "getParams: ");
return super.getParams();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question