0

Im having problem with caching image with Glide.

My sample code is like this.

items.forEach { item ->
    Glide.with(context)
                .asBitmap()
                .apply(requestOptions)
                .diskCacheStrategy(DiskCacheStrategy.DATA)
                .load(item.url)
                .into(object : CustomTarget<Bitmap>() {
                    override fun onLoadCleared(placeholder: Drawable?) {

                    }

                    override fun onResourceReady(
                        resource: Bitmap,
                        transition: Transition<in Bitmap>?
                    ) {


                    }
                })
}

I want to cache the data in first for loop, and after first loop is over, the glide should not request to remote url, should use cache. I tested with the DiskCacheStrategy options, but it didn't work. Anyone who can solve this problem, please help me...

  • https://stackoverflow.com/questions/37964187/preload-multiple-images-with-glide – ADM Jan 10 '23 at 06:07

0 Answers0