0

I am using this project universal-image-loader in order to display in a gridview several images. But I would like to modify these images with some html (for example add ads at the bottom of each images).

I saw the image are displayed by calling imageLoader.displayImage(..), in the method getView of the ImageAdapter.

I don't know what approach is better:

  • add a step in displayImage(...) in order to create a webview with my image and html and transform this webview in bitmap?

  • modify the getView of ImageAdapter which will create the webview and add an argument webview in displayeImage()?

  • ...

  • ...

I guess I don't have the choice, I have to use a webview.

Moreover in the method displayImage() of ImageLoader.java, i don't understand where the images are loaded, I guess this is somewhere in this line, but when I am looking in these methods I can't find/understand

    ImageSize targetSize = getImageSizeScaleTo(imageView);
    String memoryCacheKey = MemoryCacheUtil.generateKey(uri, targetSize);
    cacheKeysForImageViews.put(imageView.hashCode(), memoryCacheKey);
    Bitmap bmp = configuration.memoryCache.get(memoryCacheKey);

(How from a string built by an uri and ImageSize we can have a bitmap? where is the image?)

BenMorel
  • 34,448
  • 50
  • 182
  • 322
GermainGum
  • 1,349
  • 3
  • 15
  • 40

1 Answers1

1

Images are loaded asynchronously. So your code piece is just a top of complex logic. Main work is done in LoadAndDisplayTask class but you don't need to touch it.

For your case you can create own BitmapDisplayer:

  • create BitmapDisplayer implementation
  • implement Bitmap display(Bitmap bitmap, ImageView imageView) method
  • in this method you can process incoming Bitmap as you want
  • set result Bitmap in ImageView and return result

Set your BitmapDisplayer into configuration.

nostra13
  • 12,377
  • 3
  • 33
  • 43
  • Thank you for your help. So if I understand well, the modification on the image are down in the step 3? But how can I modify a Bitmap with HTML? – GermainGum Dec 17 '12 at 22:28
  • 1
    With HTML? I don't know. You can try to use canvas for drawaing on Bitmap. But if you want to use HTML then you should use WebView I guess. – nostra13 Dec 18 '12 at 08:30
  • Do you know if there is a way to overlapping each imageview of the gridview with a webview? – GermainGum Dec 19 '12 at 01:50
  • Ok thanks for your help finally I just add a webview in the ImagePagerActivity and give up the idea to put in a gridview. – GermainGum Dec 20 '12 at 01:12