Glide 4.0.0 下之載入本地快取的圖片

夢書發表於2017-09-06

在網上搜了下,無意中發現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();
        }

這下可以在專案中使用了

相關文章