如何在 recyclerview 中只加载新图像而不加载旧图像?

How to load only new images in recyclerview but not the old images?

我在 android 中使用回收器视图,现在我面临的问题是,每当我滚动时,以前的图像会再次从服务器加载,但因为我已经加载过它们,所以我不想从中获取它们服务器一次又一次所以有人可以帮我解决我如何只从服务器加载适配器中新获取的图像。

我的代码我正在使用 picasso 库在 recyclerview 将数据绑定到 recyclerview 时加载图像

@Override
    public void onBindViewHolder(ViewHolder holder, int position) {

        Log.d("mmmm", image_url.get(position));
        Log.d("scroll", "fir aya");
        Picasso.with(context).load("http://192.168.0.15:1337/offers/" + image_url.get(position)).into(holder.imageView);

    }

Picasso 有自动缓存,我想你不能配置它。 UniversalImageLoader 为您提供配置缓存设置的选项,也许您应该尝试一下。

Picasso 具有自动缓存,但您也可以使用以下代码配置其缓存大小

Picasso picasso = new Picasso.Builder(context).memoryCache(
        new LruCache(cacheSize)).build();
        int memClass = ((ActivityManager) mApplicationContext
        .getSystemService(Context.ACTIVITY_SERVICE))
        .getLargeMemoryClass();
        int cacheSize = 1024 * 1024 * memClass / 4;