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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章