Back to project page Wardrobe_app.
The source code is released under:
Apache License
If you think the Android project Wardrobe_app 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 com.android.busolo.apps.wardrobe.utils; //from w w w . ja v a2 s .co m import android.app.Application; import android.text.TextUtils; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.toolbox.ImageLoader; import com.android.volley.toolbox.Volley; /** * Created by james on 27/05/14. */ public class VolleyAppController extends Application { public static final String LOG_TAG = VolleyAppController.class.getSimpleName(); private RequestQueue requestQueue; private ImageLoader imageLoader; private static VolleyAppController instance; @Override public void onCreate(){ super.onCreate(); instance = this; } public static synchronized VolleyAppController getInstance(){ return instance; } public RequestQueue getRequestQueue(){ if(requestQueue == null){ requestQueue = Volley.newRequestQueue(getApplicationContext()); } return requestQueue; } public ImageLoader getImageLoader(){ getRequestQueue(); if(imageLoader == null){ imageLoader = new ImageLoader(this.requestQueue, new LruBitmapCache()); } return this.imageLoader; } public <T> void addToRequestQueue(Request<T> request, String tag){ //set default tag if tag is empty request.setTag(TextUtils.isEmpty(tag) ? LOG_TAG : tag); getRequestQueue().add(request); } public void cancelPendingRequest(Object tag){ if(requestQueue != null){ requestQueue.cancelAll(tag); } } }