GankClient(JAVA)技术浅析(三)--Glide

Glide图片加载库,减少图片OOM问题;

导入

dependences{
implementation "com.github.bumptech.glide:glide:4.4.0"
annotationProcessor "com.github.bumptech.glide:compiler:4.4.0"
//包含 OkHttp3 集成库,Glide 自动开始使用 OkHttp 来加载图片
implementation "com.github.bumptech.glide:okhttp3-integration:4.4.0"
}

v4使用

  • 与v3 增加了RequestOptions处理占位符,图片缩放方式,可复用
RequestOptions options = new RequestOptions()
                .placeholder(colorDrawable)
                .centerCrop();
        Glide.with(mContext)
                .load(url)
                .apply(options)
                .transition(DrawableTransitionOptions.withCrossFade())
                .into(ivImage)
        ;

Proguard

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
    **[] $VALUES;
    public *;
}

github

GankClient源码地址:

https://github.com/LinweiJ/GankClient

你可能感兴趣的:(android)