I'm using volley
for make HTTP
requests from my Android application.
Here is the code I'm using:
public class RequestPool {
private static RequestPool mInstance;
private RequestQueue mRequestQueue;
private static Context mContext;
private RequestPool(Context context) {
mContext = context;
mRequestQueue = getRequestQueue();
}
public static synchronized RequestPool getInstance(Context context) {
if (mInstance == null) {
mInstance = new RequestPool(context);
}
return mInstance;
}
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
// getApplicationContext() is key, it keeps you from leaking the
// Activity or BroadcastReceiver if someone passes one in.
mRequestQueue = Volley.newRequestQueue(mContext.getApplicationContext());
}
return mRequestQueue;
}
public <T> void addToRequestQueue(Request<T> req) {
getRequestQueue().add(req);
}
}
I want to add requests to the queue but control the way they are executed, for example:
adding multiple requests to the pool at arbitrary times, the pool will execute only the first request (head of queue), then when finishes will execute the next one ... and so on....
Maybe there is a way to make both serial and parallel requests executing?
Is it possible?
Thanks.