1. Gilde loading animation (only fade in and fade out)
Glide.with(mContext)
.load(Uri.parse(rb.getThumb()))
.transition(DrawableTransitionOptions.withCrossFade(100))//淡入淡出100m
.into(holder.imageView);
2. There are two Bitmap methods for Gilde to obtain pictures:
①.
Glide.with(this)
.asBitmap()
.load(path)
.signature(new ObjectKey(updateTime))
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
//这里的resource便是bitmap
//要在with后面加入.asBitmap才可以获取到Bitmap
}
});
②.
Glide.with(this)
.asBitmap()
.load(path)
.listener(new RequestListener<Bitmap>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
//这是图片初始化准备的方法
//这里回调也是有Bitmap的
return false;
}
})
.into(imageView);
3. Gilde prohibits the use of cache (I prefer to use it)
In some scenarios, Glide's cache reuse mechanism is not suitable, such as repeated operations on modified pictures, etc.
//取得时间
String updateTime= String.valueOf(System.currentTimeMillis());
//signature方法是前面key 已经单独接口ObjecyKey将时间传递
Glide.with(this)
.asBitmap()
.load(path)
.signature(new ObjectKey(updateTime))
.init(imageView);