Back to project page SeeKampf.
The source code is released under:
GNU General Public License
If you think the Android project SeeKampf 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 net.avedo.seekampf.core; //from w w w . j a v a2s . com import android.app.Activity; import android.os.Bundle; import android.text.TextUtils; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.VolleyLog; import com.android.volley.toolbox.Volley; public class VolleyActivity extends Activity { public static final String TAG = "VolleyPatterns"; private static VolleyActivity instance; private RequestQueue requestQueue; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize the singleton. instance = this; } public static synchronized VolleyActivity getInstance() { return instance; } public RequestQueue getRequestQueue() { if (requestQueue == null) { requestQueue = Volley.newRequestQueue(getApplicationContext()); } return requestQueue; } public <T> void addToRequestQueue(Request<T> req, String tag) { // Set the default tag if tag is empty, ... req.setTag(TextUtils.isEmpty(tag) ? TAG : tag); // ... leave a message in volly's log ... VolleyLog.d("Adding request to queue: %s", req.getUrl()); // ... and add the request to the queue. getRequestQueue().add(req); } public <T> void addToRequestQueue(Request<T> req) { // Set the default tag if tag is empty ... req.setTag(TAG); // ... and add the request to the queue. getRequestQueue().add(req); } public void cancelPendingRequests(Object tag) { if (requestQueue != null) { requestQueue.cancelAll(tag); } } }