Search code examples
androidmultithreadinguniversal-image-loader

Is there an option to make ImageLoader.display(...) call block current (UI) thread until image is loaded?


Yes, I know that I am doing bad things, but...
In some cases I'm using the nostra13's ImageLoader to load images from res/drawable folders. Is there a built-in option to block UI thread while image is loading?

I suspect that there may not be such thing, because the primary goal of ImageLoader is to load images from the Internet, and in this case asynchronous mode is the only option. But in my situation this would be handy. Currently I'm using it for loading and downscaling big background images and it takes some noticeable time.


Solution

  • There's now a method which can load and scale Bitmap synchronously: https://github.com/nostra13/Android-Universal-Image-Loader/blob/master/library/src/com/nostra13/universalimageloader/core/ImageLoader.java#L550

    But it's almost never a good idea to do this, because GUI applications should be responsive, that means — never block UI thread for a noticeable time.