package com.wangbb.naruto.http; import android.content.Context; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.toolbox.Volley; /** * Created by wangbinbin on 15/5/7. */ public class RequestManager { private static RequestQueue mRequestQueue; private RequestManager() { // no instances } public static void init(Context context) { mRequestQueue = Volley.newRequestQueue(context); } public static RequestQueue getRequestQueue() { if (mRequestQueue != null) { return mRequestQueue; } else { throw new IllegalStateException("RequestQueue not initialized"); } } public static void addRequest(Request<?> request, Object tag) { if (tag != null) { request.setTag(tag); } mRequestQueue.add(request); } public static void cancelAll(Object tag) { mRequestQueue.cancelAll(tag); } }