public CacheManager getCacheManager() { if (cacheManager == null) { cacheManager = new SoftMapCache(); } return cacheManager; }
@Override public void clean() { reset(); }
/** * It is possible to set a specific percentage of memory to be used only for images. * * @param context * @param percentageOfMemoryForCache 1-80 */ public LruBitmapCache(Context context, int percentageOfMemoryForCache) { int memClass = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass(); this.capacity = calculateCacheSize(memClass, percentageOfMemoryForCache); reset(); }
private Bitmap getResourceAsBitmap(ImageWrapper w, int resId) { Bitmap b = loaderSettings.getResCacheManager().get("" + resId, w.getWidth(), w.getHeight()); if (b != null) { return b; } b = loaderSettings.getBitmapUtil().decodeResourceBitmapAndScale(w, resId, loaderSettings.isAllowUpsampling()); loaderSettings.getResCacheManager().put(String.valueOf(resId), b); return b; }
private Bitmap getImageFromFile(File imageFile) { Bitmap b; if (loaderSettings.isAlwaysUseOriginalSize()) { b = loaderSettings.getBitmapUtil().decodeFile(imageFile, width, height); } else { b = loaderSettings.getBitmapUtil().decodeFileAndScale(imageFile, width, height, loaderSettings.isAllowUpsampling()); } if (b == null) { // decoding failed loaderSettings.getCacheManager().remove(url); return b; } if (saveScaledImage) { saveScaledImage(imageFile, b); } loaderSettings.getCacheManager().put(url, b); return b; }
private Bitmap getCachedBitmap(ImageWrapper w) { return loaderSettings.getCacheManager().get(w.getUrl(), w.getHeight(), w.getWidth()); }
/** * Normal image manager settings */ private void normalImageManagerSettings() { imageManager = new ImageManager(this, new SettingsBuilder() .withCacheManager(new LruBitmapCache(this)) .build(this)); }
@Override protected void onBitmapLoaded(ImageWrapper iw, Bitmap bmp) { new BitmapDisplayer(bmp, iw).runOnUiThread(); SimpleLoader.this.loaderSettings.getCacheManager().put(iw.getUrl(), bmp); onImageLoaded(iw.getImageView()); } };
private Bitmap getNotFoundImage() { String key = "resource" + notFoundResourceId + width + height; Bitmap b = loaderSettings.getResCacheManager().get(key, width, height); if (b != null) { return b; } if (context != null){ if (loaderSettings.isAlwaysUseOriginalSize()) { b = loaderSettings.getBitmapUtil().decodeResourceBitmap(context, width, height, notFoundResourceId); } else { b = loaderSettings.getBitmapUtil().decodeResourceBitmapAndScale(context, width, height, notFoundResourceId, loaderSettings.isAllowUpsampling()); } loaderSettings.getResCacheManager().put(key, b); } return b; }
private Bitmap getPreviewCachedBitmap(ImageWrapper w) { return loaderSettings.getCacheManager().get(w.getPreviewUrl(), w.getPreviewHeight(), w.getPreviewWidth()); }
public CacheManager getResCacheManager() { if (resCacheManager == null) { resCacheManager = new SoftMapCache(); } return resCacheManager; }
settingsBuilder.withCacheManager(new LruBitmapCache(this));
private void setResource(ImageWrapper w, int resId) { Bitmap b = loaderSettings.getResCacheManager().get("" + resId, w.getWidth(), w.getHeight()); if (b != null) { w.setBitmap(b, false); return; } b = loaderSettings.getBitmapUtil().decodeResourceBitmapAndScale(w, resId, loaderSettings.isAllowUpsampling()); loaderSettings.getResCacheManager().put("" + resId, b); w.setBitmap(b, false); }
@Override public void load(ImageView imageView) { ImageWrapper w = new ImageWrapper(imageView); try { Bitmap b = loaderSettings.getCacheManager().get(w.getUrl(), w.getWidth(), w.getHeight()); if (b != null && !b.isRecycled()) { w.setBitmap(b, false); return; } String thumbUrl = w.getPreviewUrl(); if (thumbUrl != null) { b = loaderSettings.getCacheManager().get(thumbUrl, w.getPreviewHeight(), w.getPreviewWidth()); if (b != null && !b.isRecycled()) { w.setBitmap(b, false); } else { setResource(w, w.getLoadingResourceId()); } } else { setResource(w, w.getLoadingResourceId()); } if (w.isUseCacheOnly()) { return; } singleThreadedLoader.push(w); } catch (ImageNotFoundException inf) { setResource(w, w.getNotFoundResourceId()); } catch (Throwable t) { setResource(w, w.getNotFoundResourceId()); } }