From d8ab8f297f69958722e53c38a918185231920d0c Mon Sep 17 00:00:00 2001 From: inorichi Date: Wed, 27 Jan 2016 19:42:01 +0100 Subject: [PATCH] Let Glide cache local covers, it improves performance loading the covers from the library --- .../eu/kanade/tachiyomi/data/cache/CoverCache.java | 2 +- .../kanade/tachiyomi/data/cache/CoverGlideModule.java | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.java b/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.java index e76bcf34d3..3b44ed1d0f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.java +++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.java @@ -223,7 +223,7 @@ public class CoverCache { private void loadFromCache(ImageView imageView, File file) { Glide.with(context) .load(file) - .diskCacheStrategy(DiskCacheStrategy.NONE) + .diskCacheStrategy(DiskCacheStrategy.RESULT) .centerCrop() .into(imageView); } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverGlideModule.java b/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverGlideModule.java index e3613ed560..c02cf9ce79 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverGlideModule.java +++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverGlideModule.java @@ -5,6 +5,7 @@ import android.content.Context; import com.bumptech.glide.Glide; import com.bumptech.glide.GlideBuilder; import com.bumptech.glide.load.DecodeFormat; +import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory; import com.bumptech.glide.module.GlideModule; /** @@ -12,14 +13,14 @@ import com.bumptech.glide.module.GlideModule; */ public class CoverGlideModule implements GlideModule { - - /** - * Bitmaps decoded from most image formats (other than GIFs with hidden configs), will be decoded with the - * ARGB_8888 config. - */ @Override public void applyOptions(Context context, GlideBuilder builder) { + // Bitmaps decoded from most image formats (other than GIFs with hidden configs) + // will be decoded with the ARGB_8888 config. builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888); + + // Set the cache size of Glide to 15 MiB + builder.setDiskCache(new InternalCacheDiskCacheFactory(context, 15 * 1024 * 1024)); } @Override