public interface ImageLoader
| Modifier and Type | Method and Description |
|---|---|
void |
loadImageInto(java.net.URL imageUrl,
android.widget.ImageView imageView,
android.graphics.drawable.Drawable placeholder)
Load the image at the given URL and set it in the given image view when finished.
|
void |
preload(java.net.URL imageUrl)
Preload the image at the given URL.
|
void preload(@NonNull
java.net.URL imageUrl)
throws java.lang.Exception
This method is called before the rendering of the native Ad and lets you start downloading
images and caching them in order to have them ready to be rendered when loadImageInto(URL, ImageView, Drawable) is called.
Implementation is expected to move in a worker thread when doing long task such as network to download the image.
imageUrl - URL of the image to preloadjava.lang.ExceptionloadImageInto(URL, ImageView, Drawable)@UiThread
void loadImageInto(@NonNull
java.net.URL imageUrl,
@NonNull
android.widget.ImageView imageView,
@Nullable
android.graphics.drawable.Drawable placeholder)
throws java.lang.Exception
The given image URL is in HTTPS and represents images in PNG, WebP or JPEG format.
This method is called on the UI-thread, so you can prepare the image view as you need. Implementation is expected to move in a worker thread when doing long task such as network to download the image. Also, having a caching mechanism is recommended to minimize network calls and avoid flickering effects in your RecyclerViews.
If you're using RecyclerViews, then the implementation should be aware that an image view can be recycled and reused for another URL. This also means that a given image view may contain an old image. If you need to do any operations outside the UI-thread, you're expected to clean the state of the view by setting the given placeholder. If you're using an image loading library, it generally already takes care of that.
imageUrl - URL of the image to loadimageView - the image view to fillplaceholder - that you defined the CriteoMediaViewjava.lang.Exception