Redmi note 4没有显示来自缓存滑行的图像

问题描述 投票:0回答:1

我正在使用带有磁盘缓存的Glide 4.1.1加载图像,并且它在Red Mi note 4之外的其他设备上完美运行.Red Mi 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);
android android-glide
1个回答
1
投票

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

    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 documentation

© www.soinside.com 2019 - 2024. All rights reserved.