I am loading images using Glide 4.1.1 with disk caching and it's working perfectly on other devices than Red Mi note 4. Red Mi note 4 not showing any cached image. while my emulator and Micromax android one are showing cached images perfectly.
Glide.with(context)
.load(stringUrl).apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.RESOURCE))
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
viewHolderListener.onLoadCompleted(image, adapterPosition);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
L.d(loadedData.get(adapterPosition).getImagePath());
viewHolderListener.onLoadCompleted(image, adapterPosition);
return false;
}
})
.into(image);
Try and update the glide library to new version
dependencies {
implementation ("com.github.bumptech.glide:glide:4.9.0") {
exclude group: "com.android.support"
}
Most important you have to include AppGlide module in your application
package com.example.myapp;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
@GlideModule
public final class MyAppGlideModule extends AppGlideModule {}
Finally you can enable caching by writing below code:
GlideApp.with(fragment)
.load(url)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imageView);
Refer: GlideV4 documentation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.