public class MyGlideEngine implements ImageEngine {
@Override
public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {
RequestOptions options = new RequestOptions()
.centerCrop()
.placeholder(placeholder)//这里可自己添加占位图
.override(resize, resize);
Glide.with(context)
.asBitmap() // some .jpeg files are actually gif
.load(uri)
.apply(options)
.into(imageView);
}
@Override
public void loadGifThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {
RequestOptions options = new RequestOptions()
.centerCrop()
.placeholder(placeholder)//这里可自己添加占位图
.override(resize, resize);
Glide.with(context)
.asGif() // some .jpeg files are actually gif
.load(uri)
.apply(options)
.into(imageView);
}
@Override
public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
RequestOptions options = new RequestOptions()
.centerCrop()
.override(resizeX, resizeY)
.priority(Priority.HIGH);
Glide.with(context)
.load(uri)
.apply(options)
.into(imageView);
}
@Override
public void loadGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
RequestOptions options = new RequestOptions()
.centerCrop()
.override(resizeX, resizeY);
Glide.with(context)
.asGif() // some .jpeg files are actually gif
.load(uri)
.apply(options)
.into(imageView);
}
@Override
public boolean supportAnimatedGif() {
return true;
}
}
混淆Glide
-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.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
# for DexGuard only
-keepresourcexmlelements manifest/application/meta-data@value=GlideModule
-dontwarn com.squareup.picasso.**