Glide 4.0.0 下之加载本地缓存的图片

在网上搜了下,无意中发现RequestOptions还有个方法: onlyRetrieveFromCache

用了下是OK的

        try {
            File imageFile = Glide.with(context).asFile()
                    .apply(RequestOptions.priorityOf(Priority.HIGH).onlyRetrieveFromCache(true))
                    .load(image.getFullUrl())
                    .submit().get();
            if(imageFile != null && imageFile.exists()){

                if(IConfig.DEBUG) Log.d("XXX", "found the file:" + imageFile.getAbsolutePath());
                
            }
        }catch (Exception e){
            e.printStackTrace();
        }

这下可以在项目中使用了

原文地址:https://www.cnblogs.com/mengshu-lbq/p/7484986.html