繁体   English   中英

Redmi Note 4未显示来自缓存滑动的图像

[英]Redmi note 4 not showing images from cache glide

我正在使用具有磁盘缓存的Glide 4.1.1加载图像,并且它在Red Mi note 4之外的其他设备上运行良好。RedMi note 4没有显示任何缓存的图像。 而我的模拟器和Micromax android则完美地显示了缓存的图像。

 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);

尝试将滑行库更新为新版本

    dependencies {
  implementation ("com.github.bumptech.glide:glide:4.9.0") {
    exclude group: "com.android.support"
  }

最重要的是您必须在应用程序中包含AppGlide模块

package com.example.myapp;

import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;

@GlideModule
public final class MyAppGlideModule extends AppGlideModule {}

最后,您可以通过编写以下代码来启用缓存:

GlideApp.with(fragment)
  .load(url)
  .diskCacheStrategy(DiskCacheStrategy.ALL)
  .into(imageView);

请参阅: GlideV4文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM