Created
April 25, 2016 16:37
-
-
Save mmanishh/811d90849e7e11c504b22dd702f8ea0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.androidhive.volleyexamples.app; | |
import info.androidhive.volleyexamples.volley.utils.LruBitmapCache; | |
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; | |
public class AppController extends Application { | |
public static final String TAG = AppController.class | |
.getSimpleName(); | |
private RequestQueue mRequestQueue; | |
private static AppController mInstance; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
mInstance = this; | |
} | |
public static synchronized AppController getInstance() { | |
return mInstance; | |
} | |
public RequestQueue getRequestQueue() { | |
if (mRequestQueue == null) { | |
mRequestQueue = Volley.newRequestQueue(getApplicationContext()); | |
} | |
return mRequestQueue; | |
} | |
public <T> void addToRequestQueue(Request<T> req) { | |
req.setTag(TAG); | |
getRequestQueue().add(req); | |
} | |
public void cancelPendingRequests(Object tag) { | |
if (mRequestQueue != null) { | |
mRequestQueue.cancelAll(tag); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment