We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RequestQueue queue = MySingleton.getInstance(this.getApplicationContext()). getRequestQueue(); MySingleton.getInstance(this).addToRequestQueue(stringRequest);
https://github.com/CypressNorth/Volley-Singleton/blob/master/VolleySingleton.java
https://google.github.io/volley/requestqueue.html
`public class MySingleton { private static MySingleton instance; private RequestQueue requestQueue; private ImageLoader imageLoader; private static Context ctx;
private MySingleton(Context context) { ctx = context; requestQueue = getRequestQueue(); imageLoader = new ImageLoader(requestQueue, new ImageLoader.ImageCache() { private final LruCache<String, Bitmap> cache = new LruCache<String, Bitmap>(20); @Override public Bitmap getBitmap(String url) { return cache.get(url); } @Override public void putBitmap(String url, Bitmap bitmap) { cache.put(url, bitmap); } }); } public static synchronized MySingleton getInstance(Context context) { if (instance == null) { instance = new MySingleton(context); } return instance; } public RequestQueue getRequestQueue() { if (requestQueue == null) { // getApplicationContext() is key, it keeps you from leaking the // Activity or BroadcastReceiver if someone passes one in. requestQueue = Volley.newRequestQueue(ctx.getApplicationContext()); } return requestQueue; } public <T> void addToRequestQueue(Request<T> req) { getRequestQueue().add(req); } public ImageLoader getImageLoader() { return imageLoader; }
}
The text was updated successfully, but these errors were encountered:
sondosaabed
No branches or pull requests
https://github.com/CypressNorth/Volley-Singleton/blob/master/VolleySingleton.java
https://google.github.io/volley/requestqueue.html
`public class MySingleton {
private static MySingleton instance;
private RequestQueue requestQueue;
private ImageLoader imageLoader;
private static Context ctx;
}
The text was updated successfully, but these errors were encountered: