Refine search
@Override protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) { try { String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET)); JSONObject result = null; if (jsonString != null && jsonString.length() > 0) result = new JSONObject(jsonString); return Response.success(result, HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (JSONException je) { return Response.error(new ParseError(je)); } }
@Override public String getMessage() { StringBuilder sb = new StringBuilder(); for (ParseError err : errors) { if (sb.length() > 0) { sb.append('\n'); } sb.append(err.getMessage()); } return sb.toString(); }
public JsonUTF8Request(int method, String url, JSONObject jsonRequest, Listener<JSONObject> listener, ErrorListener errorListener) { super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener, errorListener); String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); return Response.success(new JSONObject(jsonString), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (JSONException je) { return Response.error(new ParseError(je));
public class MetaRequest extends JsonObjectRequest { public MetaRequest(int method, String url, JSONObject jsonRequest, Response.Listener <JSONObject> listener, Response.ErrorListener errorListener) { super(method, url, jsonRequest, listener, errorListener); } public MetaRequest(String url, JSONObject jsonRequest, Response.Listener<JSONObject> listener, Response.ErrorListener errorListener) { super(url, jsonRequest, listener, errorListener); } @Override protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) { try { String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET)); JSONObject jsonResponse = new JSONObject(jsonString); jsonResponse.put("headers", new JSONObject(response.headers)); return Response.success(jsonResponse, HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (JSONException je) { return Response.error(new ParseError(je)); } } }
public class CustomJsonArrayRequest extends JsonRequest<JSONArray> { /** * Creates a new request. * @param method the HTTP method to use * @param url URL to fetch the JSON from * @param jsonRequest A {@link JSONObject} to post with the request. Null is allowed and * indicates no parameters will be posted along with request. * @param listener Listener to receive the JSON response * @param errorListener Error listener, or null to ignore errors. */ public CustomJsonArrayRequest(int method, String url, JSONObject jsonRequest, Listener<JSONArray> listener, ErrorListener errorListener) { super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener, errorListener); } @Override protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) { try { String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET)); return Response.success(new JSONArray(jsonString), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (JSONException je) { return Response.error(new ParseError(je)); } } }
@Override public void displayRecognitionError(String[] tokenNames, RecognitionException e) { gParent.errors.add(new ParseError(gParent, e, tokenNames)); }
JSONObject jsonObject = new JSONObject(); if (json instanceof JSONObject) { jsonObject = (JSONObject) json; } else if (json instanceof JSONArray) { jsonObject.put("success", json); } else { String message = "{\"error\":\"Unknown Error\",\"code\":\"failed\"}"; jsonObject = new JSONObject(message); return Response.error(new ParseError(e)); } catch (JSONException e) { return Response.error(new ParseError(e));
super(m,url,params.toString(),listener,errorListener); HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e));
@Override public void displayRecognitionError(String[] tokenNames, RecognitionException e) { gParent.errors.add(new ParseError(gParent, e, tokenNames)); }
String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); return Response.success(new JSONObject(jsonString), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (JSONException je) { return Response.error(new ParseError(je));
@Override public void displayRecognitionError(String[] tokenNames, RecognitionException e) { errors.add(new ParseError(this, e, tokenNames)); }
@Override public String getMessage() { StringBuilder sb = new StringBuilder(); for (ParseError err : errors) { if (sb.length() > 0) { sb.append('\n'); } sb.append(err.getMessage()); } return sb.toString(); }
final String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); return Response.success(new JSONObject(jsonString), cacheEntry); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (JSONException e) { return Response.error(new ParseError(e));
@Override public void displayRecognitionError(String[] tokenNames, RecognitionException e) { errors.add(new ParseError(this, e, tokenNames)); }
@Override public String getMessage() { StringBuilder sb = new StringBuilder(); for (ParseError err : errors) { sb.append(err.getMessage()); sb.append("\n"); } return sb.toString(); }
String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); return Response.success(new JSONObject(jsonString), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (JSONException je) { return Response.error(new ParseError(je));
@Override public void displayRecognitionError(String[] tokenNames, RecognitionException e) { gParent.errors.add(new ParseError(gParent, e, tokenNames)); }
@Override public String getMessage() { StringBuilder sb = new StringBuilder(); for (ParseError err : errors) { if (sb.length() > 0) { sb.append('\n'); } sb.append(err.getMessage()); } return sb.toString(); }
String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); return Response.success(new JSONObject(jsonString), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (JSONException je) { return Response.error(new ParseError(je));
@Override public void displayRecognitionError(String[] tokenNames, RecognitionException e) { gParent.errors.add(new ParseError(gParent, e, tokenNames)); }