Glide

获取缓存的路径

获取缓存的路径

指是定缓存路径获取缓存的路径

指定缓存路径

with方法

with方法

 

with方法with

Requeswith方法tManagerRetriever.get方法

RequestManagerRetrieRequestManagerRetriever.get方法RequestManagerRetriever.get方法RequestManagerRetriever.get方法RequestManagerRetriev

er.get方法ver.geRequestManagerRe

requestMananferRetriver。get()questRetriever.get方法t方法RequestManagerRetriever.get方法

return 返回的值就

是否在主线程

 

这里其实就是就是将我们传进来的activity转化为glide需要的RequestManagerFragment,RequestManagerFragment是一个自己重新以的fragment而已。

with函数:

Glide会根据我们传入with()方法的参数来确定图片加载的生命周期,

load函数

将你要传递的uri,file等等传进来,放到RequestBuilder(请求构建器)中。

into函数

在into函数中,有一行代码:requestManager.track(target, request);k个就是最核心的方法,它才是真正触发请求、编解码、装载、缓存等这些功能的

 

with() 传入对象 Context,Activity,Fragment,Glide会与当前传入值的生命周期一致。

load() 对象: String(文件路径,网络地址),File(文件资源),Integer(资源id)。

asGif() 表示的gif动画,asBitmap:表示静态图。

diskCacheStrategy() 表示磁盘缓存策略。

1.DiskCacheStrategy.RESULT:展示小大的图片缓存

2.DiskCacheStrategy.ALL; 展示在控件中大小图片尺寸和原图都会缓存

3.DiskCacheStrategy.NONE:不设置缓存

4.DiskCacheStrategy.SOURCE:原图缓存

override() 设置图片的width,height

placeholder() 设置占位图

error() 设置失败图

thumbnail() 缩略图显示传入值(0-1f)

crossFade() 显示动画-淡入淡出

transform() 设置图片圆角或圆形显示(继承 BitmapTransformation)这都是很常用的哦

centerCrop() 图片显示类型 fitCenter();

into() 显示到ImageView上

Glide.with(this).load(imageUrl).placeholder(R.mipmap.ic_launcher).error(R.mipmap.ic_launcher).into(imageView);

另外Glide还提供了清除缓存的实现

Glide.get(context).clearDiskCache();(清除磁盘缓存) 

Glide.get(context).clearMemory();(清除内存缓存) 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值