目录
5 Glide加载GIF
5.1 和图片一样加载GIF
private String gifUrl = "https://upfile.asqql.com/2009pasdfasdfic2009s305985-ts/2018-11/201811301685857474.gif";
Glide.with(context).load(gifUrl).into(imgView);
5.2 asBitmap()
加载GIF的第一帧图片,
private String gifUrl = "https://upfile.asqql.com/2009pasdfasdfic2009s305985-ts/2018-11/201811301685857474.gif";
Glide.with(context).asBitmap().load(gifUrl).into(imgView);
5.3 asGif()
判断是否是GIF文件,不是显示error设置的图片;
private String gifUrl = "https://upfile.asqql.com/2009pasdfasdfic2009s305985-ts/2018-11/201811301685857474.gif";
options = new RequestOptions().error(R.mipmap.img_error);
Glide.with(context).asGif().load(gifUrl).apply(options).into(imgView);
5.4 加载视频
加载视频的第一帧,并且diskCacheStrategy(DiskCacheStrategy.RESOURCE)设置缓存到本地,提供加载性能;
String videoUrl = "http://gmp4.dwstatic.com/1901/6445176136.mp4";
options = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.RESOURCE).
placeholder(R.mipmap.img1).error(R.mipmap.img_error);
Glide.with(context).load(R.raw.video).apply(options).into(imgView);