Back to project page KnightNews_Android.
The source code is released under:
Copyright (c) 2014, James Van Gaasbeck All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are m...
If you think the Android project KnightNews_Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package knightnews.android; /* w w w . ja v a 2 s . c o m*/ import android.content.Context; import android.text.TextUtils; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.toolbox.Volley; public class RequestManager { private static final String TAG = "RequestManager"; private static RequestManager sInstance = null; private RequestQueue mRequestQueue; private Context mAppContext; private RequestManager(Context appContext) { mAppContext = appContext; mRequestQueue = Volley.newRequestQueue(mAppContext); } public static RequestManager getInstance(Context context) { if (sInstance == null) { sInstance = new RequestManager(context.getApplicationContext()); } return sInstance; } public RequestQueue getRequestQueue() { return mRequestQueue; } public <T> void addToRequestQueue(Request<T> req, String tag) { req.setTag(TextUtils.isEmpty(tag) ? TAG : tag); //VolleyLog.d("Adding request to queue: %s", req.getUrl()); getRequestQueue().add(req); } public void cancelRequestByTag(String tag) { getRequestQueue().cancelAll(tag); } }