Cache Images before showing with Glide on Android

    private fun cacheFiles(files: List<MediaFile>?) {
        if (files != null) {

            val measuredWidth = Statics.getScreenWidth() / 4
            //val requestOption = RequestOptions.overrideOf(width, width)

            for (f in files) {
                if (f.mimeType.startsWith("image")) {
                    GlideApp.with(CachePupli.context)
                            .load(File(f.path))
                            .diskCacheStrategy(DiskCacheStrategy.ALL)
                            .override(measuredWidth, measuredWidth)
                            .centerCrop()
                            .submit(measuredWidth, measuredWidth)
                }
            }
        }
    }

References
https://github.com/bumptech/glide/wiki/Loading-and-Caching-on-Background-Threads