Created
April 14, 2015 18:16
-
-
Save yishai-glide/1f856656ed38ff466804 to your computer and use it in GitHub Desktop.
a class that inherits JsonArrayRequest but allows storing POST data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.android.volley.toolbox; | |
import org.json.JSONArray; | |
import android.text.TextUtils; | |
import com.android.volley.Response.ErrorListener; | |
import com.android.volley.Response.Listener; | |
public class MyJsonArrayRequest extends JsonArrayRequest { | |
private byte[] mPostBody = null; | |
public MyJsonArrayRequest(String url, String data, Listener<JSONArray> listener, ErrorListener errorListener) { | |
super(url, listener, errorListener); | |
if(!TextUtils.isEmpty(data)) { | |
mPostBody = data.getBytes(); | |
} | |
} | |
@Override | |
public byte[] getBody() { | |
if(mPostBody == null || mPostBody.length == 0) { | |
return super.getBody(); | |
} else { | |
return mPostBody; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment