public ImageLoader getImageLoader() { getRequestQueue(); if (imageLoader == null) { imageLoader = new ImageLoader( this.requestQueue, new LruBitmapCache(LruBitmapCache.getCacheSize(getApplicationContext()))); return imageLoader; } else return this.imageLoader; }
private RequestQueue getRequestQueue() { if (null == sAppContext) { throw new RuntimeException("Please call HttpRequestQueue.init() at first!"); } if (mRequestQueue == null) { mRequestQueue = Volley.newRequestQueue(sAppContext); } mImageLoader = new ImageLoader( mRequestQueue, new LruBitmapCache(LruBitmapCache.getCacheSize(sAppContext))); return mRequestQueue; }
private MySingleton(Context context) { mCtx = context; mRequestQueue = getRequestQueue(); mImageLoader = new ImageLoader(mRequestQueue, new LruBitmapCache(LruBitmapCache.getCacheSize(mCtx))); /*mImageLoader = new ImageLoader(mRequestQueue, 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); } });*/ }