UIL, Picasso - Images in adapter always reload when stop scrolling

前端 未结 2 1726
野趣味
野趣味 2021-02-20 07:39

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

相关标签:
2条回答
  • 2021-02-20 08:13

    Maybe your memory cache size is small and Picasso tries to load images from disc cache. Please check here for deciding cache size. You can try to increase cache size of Picasso by:

    Picasso p = new Picasso.Builder(context)
    .memoryCache(new LruCache(cacheSize))
    .build();
    

    However in my opinion your app looks like having an endless feed. Which means your memory cache will be full at some time and you'll have to use disc cache. Retrieving data from the disc cache is slower compared to memory cache.

    0 讨论(0)
  • 2021-02-20 08:22

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

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

    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!

    0 讨论(0)
提交回复
热议问题