Glide支持webp扩展

来源:互联网 发布:手机贴吧抢二楼软件 编辑:程序博客网 时间:2024/06/07 22:31

Glide的gif加载性能比fresco要好,但是Glide并不支持动态的webp,取舍后决定用fresco的webp库扩展Glide,让Glide也支持动态webp。

Glide的框架十分优秀,能简单的进行扩展,有时间会写一下Glide源码解读的文章。


使用方法:在application.onCreate里面添加下面两行,注册webp的解码器

// webp支持ResourceDecoder decoder = new WebpResourceDecoder(this);Glide.get(this).getRegistry().append(InputStream.class, Drawable.class, decoder);


项目用的是Glide jar包集成,也可以用maven集成只需要

    compile files('libs/glide-4.0.0.jar')    compile files('libs/glide-okhttp3-integration-4.0.0-SNAPSHOT.jar')//    compile 'com.github.bumptech.glide:glide:4.0.0-RC1'//    compile 'com.github.bumptech.glide:okhttp3-integration:4.0.0-RC1'
    compile "com.facebook.fresco:animated-webp:0.11.0"


把gradle里面上面两行注释,用下面两行就可以了


源码地址 :https://github.com/roths/GlideWebpSupport

原创粉丝点击