UIL,毕加索 - 适配器图片总是在停止滚动刷新 [英] UIL, Picasso - Images in adapter always reload when stop scrolling

查看:190
本文介绍了UIL,毕加索 - 适配器图片总是在停止滚动刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有从互联网上的文字和图像大的ListView。我的形象项目有合​​适的宽度和 WRAP_CONTENT 的高度。结果
我试着用 UIL &放大器,显示在背景图片; 毕加索。他们都可以工作,但是当我停止滚动的形象总是重新加载,它使ListView控件闪烁结果
它看起来像这样:搜索结果

I have ListView with text and large image from internet. My image item has fit width and wrap_content height.
I tried to display image in background with UIL & Picasso. Both of them can work but the image always reloads when I stop scrolling, and it makes ListView flickering
It looks like this:

您可以看到的重新放回下载,当我停止滚动(我向下滚动,然后滚动)缓存图像。结果
我怎样才能prevent出现这种情况?

You can see that it reload downloaded and cached images when I stop scrolling (I scroll down and then scroll up).
How can I prevent this happen?

 <ImageView android:id="@+id/imgFeed"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:scaleType="centerCrop"/>

 // UIL
 options = new DisplayImageOptions.Builder()
 .showImageOnLoading(defaultImage)
 .showImageOnFail(defaultImage)
 .showImageForEmptyUri(defaultImage)
 .resetViewBeforeLoading(false)
 .cacheOnDisk(true).delayBeforeLoading(0)
 .displayer(new  FadeInBitmapDisplayer(200)).cacheInMemory(true).imageScaleType(ImageScaleType.EXACTLY_STRETCHED).build();

 ImageAware imageAware = new ImageViewAware(viewHolder.imgFeed, false); 
 ImageLoader.getInstance().displayImage(item.getPhotoUrl(), imageAware, options);

// Picasso
 Picasso.with(getContext())
                        .load(item.getPhotoUrl())
                        .placeholder(R.drawable.place_holder_big)
                        .resize(screenWidth, 0) //set max width
                        .into(viewHolder.imgFeed);

有关UIL,我试着在这个问题但他们不我在所有的工作。

For UIL, I tried many ways in this issue but they don't work for me at all.

更新:看来我面临着内存缓存的问题像<一个href=\"http://stackoverflow.com/questions/27771646/picasso-keeps-reloading-images-while-scrolling-upwards-in-listview-loads-slowly\">this问题。但我怎么能解决这个问题?看看Facebook的应用程序,他们干得很不错。所有图像有不同的尺寸相契合的宽度,而且很平滑滚动而无需重新加载图像。他们怎么能这样做呢?

Update: seems I faced with memory cache issue like this question. But how can I fix this issue? Look at Facebook app, they did it very well. All images have different sizes with fit width, and very smooth scrolling without reloading images. How can they do that?

推荐答案

如果你想知道的Facebook是如何做到的,他们居然发布了自己的图像载入库(的 https://github.com/facebook/fresco

If you're wondering how Facebook did it, they actually released their image loading library (https://github.com/facebook/fresco)

难道你实际上是在当时的底层的ListView调用notifyDataSetChanged?另外您使用hasStableIds()?

Is it possible you are actually calling notifyDataSetChanged on the underlying ListView at that time? Also are you using hasStableIds()?

有关UIL你可以尝试使用WeakMemoryCache(参见 HTTPS ://github.com/nostra13/Android-Universal-Image-Loader/wiki/Useful-Info )作为理论上会允许你利用所有可用的内存,虽然它可能会导致很多额外的GC呼叫。

For UIL you could try using a WeakMemoryCache (refer to https://github.com/nostra13/Android-Universal-Image-Loader/wiki/Useful-Info) as that'll theoretically allow you to make use of all available memory though it may cause a lot of extra GC calls.

有关毕加索塔哈的方法看起来像你最好的选择!

For Picasso Taha's method looks like your best bet!

这篇关于UIL,毕加索 - 适配器图片总是在停止滚动刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆