I have a list adapter which shows a large photo in each row. I’m fetching the bitmap off the disk in a thread in the ListAdapter.getView() method. This works fine, but it’s slightly annoying that when the user is scrolling, they’ll see the top of a new row coming on screen with the empty ImageView. The thread to read the bitmap off disk completes pretty quickly and then the redraw happens.
Is there a good pattern in the ListAdapter world to signal that the “next” row is in danger of coming onto screen momentarily? Ideally I’d like to start a thread to load the bitmap for this invisible row and get the bitmap into my memcache, that way if the user does scroll to this cell, the bitmap will already be loaded.
I suppose I’d need to know that (1) the user is scrolling downwards and (2) the top edge of the next invisible row is approximately 20 pixels or some value away from being visible.
Thanks
Register an
AbsListView.OnScrollListener; you will be notified for the scrolling state of the list and you will also be given the current visible items. Combine these two parameters and it should be simple for you to decide whether you need to load “next” bitmaps or not.