frequent refresh listview..sometimes cause images flashing
my adapter getView was simple :
mSimpleDrawee.setImageURI(Uri.parse(item.img));
frequent call the method of notifyDataSetChanged, sometimes page kept flashing...
It seems caused by frequent load(or decode) pictures.
How to avoid it ? thank you !
Can you upload a video? What format of images are you showing, and are they network, or local?
it is difficult to reproduce... the images from network.
i will upload the video , when it's reproduced again..
thank you

i found it again, when i call the mListView.notifyDataSetChanged();,the image kept flashing
please check the gif that i was upload.
thank you!
Can you show us a code snippet?
I also wonder why only one image is affected. What kind of image is it (gif, jpeg, etc)? Is it animated?
This happens to me as well.
Here's my snippet of onBindViewHolder in RecyclerView Adapter:
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(message.getImageUrl()))
.setPostprocessor(mTransformation)
.setResizeOptions(mResizeOptions)
.build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setOldController(holder.imgAlbumArt.getController())
.setImageRequest(request)
.build();
holder.imgAlbumArt.setController(controller);
lushan1314 Did you solve this problem?
@raylee4204 - you will see this because your request includes a postprocessor, and at present postprocessed images are not stored in bitmap cache, so the postprocess step has to take place again which causes a flash.
@lushan1314 - please can you answer @tyronen's latest question so that we can try to help you?
@IanChilds Is there any future plan for postprocessed images to be stored?
It's #14 - but I don't know when/if it will get done unfortunately.
sorry, i was busy.I just saw your reply.
@tyronen the image is jpeg. my code is simple , in the ListAdapter.getView
if (StringUtils.isEmpty(user.iconUrl)) {
viewHolder.icon.setImageURI(FrescoUtils.getResUri(R.drawable.head_72));
} else {
viewHolder.icon.setImageURI(FrescoUtils.getUri(user.iconUrl));
}
in my case :
when the user clicks a button in the listview item, this line is selected,the state needs to be changed.
So I changed the list item associated the state of an object , and then call the notifyDataSetChanged(),then this problem happend.
I want to have a possibility: maybe the bitmap cache was deleted. call notifyDataSetChanged() make it reload.
But i did not understand about : the bitmap cache should not be deleted when the image is showing.
finally , i found one way solve it :
That is to find out the current display item view, and then change their status, avoid call setImageURI method again, because the notifyDataSetChanged () - > getView () - > setImageURI () something like this:
int first = mListView.getFirstVisiblePosition();
int last = mListView.getLastVisiblePosition();
View convertView;
for (int i = 0; i <= last-first; i++) {
convertView = mListView.getChildAt(i);
if (convertView != null) {
//to do someting about ui change....
}
}
@tyronen this image is not animated
Can you give a uri for the image that failed please?
you mean fresco:failureImage?
@tyronen i just tested ,GIF are happening every time, JPEG happens by chance.
@IanChilds in version 0.4.0, if image's format isn't a GIF, I can't find this problem.
but if the image is a GIF, it's still happened.
you can use a uri for gif image ,and show on a ListView . you will find it.
thank you.
As @IanChilds explained, the flash may happen if you are re-setting the image to the view and the image is not found in the bitmap cache. Postprocessed images are not stored in the bitmap cache, but we are working on supporting this as we speak. Animated images are also not stored in the bitmap cache and therefore they are susceptible to this issue. Up until recently, Fresco didn't distinguish between animated and static GIFs so the issue used to affect the static GIFs as well. This has been fixed and static GIFs should no longer be affected by this issue. That being said, with the current version of Fresco, you should only experience this issue with animated and postprocessed images.
ok , version 0.5.3?
This may have been fixed now.
楼主现在解决了吗? 我现在还有这种问题。 在5.0或者5.0.2系统上,如果MemoryCacheParams中的maxCacheSize,也就是bitmap缓存大小设置的比较小的话,一旦调用notifyDataSetChanged,listview里面的图片就会闪。 但是同样的bitmap缓存大小设置下,在5.1.1系统上就不会出现这样的问题,猜测跟5.0系统的内存泄露有一些关系,但是fresco设置也有关系,因为只要把bitmap缓存设置大一些就不会闪烁了。 不过5.0系统bitmap缓存设置大一些又容易OOM
闪烁的问题,我目前测试只有gif才会有。因为gif一般是不缓存的好像。你说的问题我没遇到,看上去是一样的,如果缓存很快就满了,很容易发生这种情况。还有一种办法有点恶心了,就是你不要调用notify,可以获取listview的可见区域做修改,并尽量不修改图片。不过不知道是否适合你的情况。缓存策略的话只能自己取舍了