ListAdapter - get the next line that appears on the screen? (to preload the bitmap)

I have a list adapter that shows a large photo on each line. I am extracting a bitmap from a disk in a stream in the ListAdapter.getView () method. This works great, but itโ€™s a little annoying that when you scroll through the user, they will see the top of the new line that appears on the screen with an empty ImageView. The stream for reading the bitmap from the disk completes quite quickly, and then redrawing occurs.

Is there a good example in the world of the ListAdapter to signal that the โ€œnextโ€ line can appear on the screen instantly? Ideally, I would like to start a stream to load a bitmap for this invisible line and get a bitmap in my memcache, so if the user scrolls to this cell, the bitmap will already be loaded.

I suppose I would need to know that (1) the user scrolls down and (2) the top edge of the next invisible line is about 20 pixels or some value is not visible.

thanks

+4
source share
1 answer

Register AbsListView.OnScrollListener ; You will be notified of the scroll status of the list, and you will also be provided with the current visible items. Combine these two options, and you will need to decide whether to load the โ€œnextโ€ bitmaps or not.

+2
source

Source: https://habr.com/ru/post/1411371/


All Articles