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

前端 未结 5 1646
一个人的身影
一个人的身影 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

    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.

提交回复
热议问题