From 6b30d9452e118b0b5781c370aa5e90cc11f435ca Mon Sep 17 00:00:00 2001 From: Joris Bolsens Date: Tue, 17 Mar 2015 20:22:26 -0700 Subject: Add support for all HTTP methods to JsonArrayRequest Change-Id: I6e89f69885a63d524c48b1dec54553d6e16edd48 Signed-off-by: Joris Bolsens --- .../java/com/android/volley/toolbox/JsonArrayRequest.java | 15 +++++++++++++++ .../java/com/android/volley/toolbox/JsonRequestTest.java | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/com/android/volley/toolbox/JsonArrayRequest.java b/src/main/java/com/android/volley/toolbox/JsonArrayRequest.java index e932a61..ba35d26 100644 --- a/src/main/java/com/android/volley/toolbox/JsonArrayRequest.java +++ b/src/main/java/com/android/volley/toolbox/JsonArrayRequest.java @@ -42,6 +42,21 @@ public class JsonArrayRequest extends JsonRequest { super(Method.GET, url, null, listener, errorListener); } + /** + * Creates a new request. + * @param method the HTTP method to use + * @param url URL to fetch the JSON from + * @param jsonRequest A {@link JSONArray} 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 JsonArrayRequest(int method, String url, JSONArray jsonRequest, + Listener listener, ErrorListener errorListener) { + super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener, + errorListener); + } + @Override protected Response parseNetworkResponse(NetworkResponse response) { try { diff --git a/src/test/java/com/android/volley/toolbox/JsonRequestTest.java b/src/test/java/com/android/volley/toolbox/JsonRequestTest.java index d999d50..e39c8c8 100644 --- a/src/test/java/com/android/volley/toolbox/JsonRequestTest.java +++ b/src/test/java/com/android/volley/toolbox/JsonRequestTest.java @@ -17,6 +17,7 @@ package com.android.volley.toolbox; import com.android.volley.Response; +import org.json.JSONArray; import org.json.JSONObject; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,6 +38,8 @@ public class JsonRequestTest { assertNotNull(JsonArrayRequest.class.getConstructor(String.class, Response.Listener.class, Response.ErrorListener.class)); + assertNotNull(JsonArrayRequest.class.getConstructor(int.class, String.class, JSONArray.class, + Response.Listener.class, Response.ErrorListener.class)); assertNotNull(JsonObjectRequest.class.getConstructor(String.class, JSONObject.class, Response.Listener.class, Response.ErrorListener.class)); -- cgit v1.2.3