Search code examples
androidlistviewgridviewandroid-viewpageruniversal-image-loader

android universal image loader for two listview in viewpager


I am using universalImageLoader in my android program.

My situation:

  • 1 viewpager(2 pages)

  • one listview on first page, one gridview on second page.

  • the listview shows images downloading from internet(lazy load),

  • the gridview shows images that are on SD card.

Both use universalImageLoader to load image.

my problem:

First, turn to page 1 of the viewpager, when the network speed is very slow, all the thread in universalImageLoader pool is downloading images of the listview, at this time , turn to page 2 of the viewpager, the gridview is empty, 'cause all the thread is downloading image, we have to wait until all the image finished downloading, and then we can see the images in gridview appeared(the images in gridview should've been shown quickly with no lag, for they are on SD card).

I want to clear the downloading thread pool of UniversalImageLoader and add new local image request when user turn to page2 so that the images on SD card can be shown quickly, but I didn't find a way to do this. there's no clearRequest() method for UniversalImageLoader

Any solutions? Thanks in advance.


Solution

  • Call ImageLoader.stop() when user turn to page2. It clears thread pool.