Picasso keeps reloading images while scrolling upwards in listview, loads slowly

前端 未结 5 1648
一个人的身影
一个人的身影 2021-02-08 00:04

I have been searching SO threads for answers but couldn\'t figure out my issue from previous discussion. I have a listview which loads about 50 images (it used to be about 100

相关标签:
5条回答
  • 2021-02-08 00:45

    use resize with picasso

     Picasso.with(context)
    .load(imageURL)
    .tag(context)
    .placeholder(R.drawable.kanye8080s)
    .error(R.drawable.stadiumarcadium)
    .into(imageView)
    .resize(x,y);
    

    //This would definitely help

    0 讨论(0)
  • 2021-02-08 00:45

    The size of the memory cache of Picasso is limited so it does not generate out of memory errors when scrolling long lists. Once the images are out of the memory cache, the placeholder will be displayed while the image is reloaded from either the disk cache or the network.

    The disk cache is enabled by default so the reload time should be very fast. You can use setIndicatorsEnabled(true) to see where the images are being loaded from.

    If you are finding that Picasso is reloading the images from network, this is probably a problem with the HTTP headers being sent from the server. I don't believe Picasso actually caches the images on disk itself, instead relying on the HTTP layer, which will obey a no-cache header, and will reload from network if the expire time elapses.

    0 讨论(0)
  • 2021-02-08 00:52

    I would suggest you to use GLIDE for image loading. Since GLIDE is fast and with its cache loading feature you can get super fast image loading, With GLIDE you get lot of features..

    Download here https://github.com/bumptech/glide

    0 讨论(0)
  • 2021-02-08 01:00

    Use :

    recyclerview.getRecycledViewPool().setMaxRecycledViews(0, 0);
    

    This solved my issue

    0 讨论(0)
  • 2021-02-08 01:02

    I'd look at two things.

    Number one is the sizes of the images being loaded. I don't know what the default maximum cache size is in Picasso, but it sounds like you may be exceeding it with just a few images, causing the others to be evicted from the cache.

    Number two is probably not the core issue, but also contributes to performance. You are doing a lot findViewById() calls, which are fairly expensive. Look into the "ViewHolder" pattern for "caching" those lookups.

    Edit - see Jake Wharton's answer to a similar question for more detail

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