Search code examples
androidlistviewimageviewrobospice

Using robospice to lazyload images in a Listview


I am using robospice and trying to lazyload a listview. I came up with couple of options and don't know which one is better or recommended.

Option 1:

  • Add all requests to spicemanager execute at once
  • Use different request listeners. Keep a variable of image position in each instance of request listener
  • Update image in callback

Option 2:

  • Add a request after completion of another
  • Using same request listener
  • Load an image and then initiate next request in onRequestSuccess callback

I think first thing I need to be clear about is if requests that are added to spicemanager are executed and finished in the same order that they are added.

I assumed it is not the case and came up with above solutions

Thanks in advance :)


Solution

  • You right there is no guarantee on order of request processing in RS. Everything is massively multithreaded and it would artificially slow done things to guarantee an order.

    I would definitely adopt option 1, not only in RS but in a sync operations at large. It looks much more robust. But if you are just trying to load data + images, did you have a look at RoboSpice UI spicelist module. It does exactly that, and we also offer a sample to see how it works.

    Stephane