public class CriteoNativeLoader
extends java.lang.Object
| Constructor and Description |
|---|
CriteoNativeLoader(com.criteo.publisher.model.NativeAdUnit adUnit,
CriteoNativeAdListener listener,
CriteoNativeRenderer renderer) |
| Modifier and Type | Method and Description |
|---|---|
android.view.View |
createEmptyNativeView(android.content.Context context,
android.view.ViewGroup parent)
Create a new empty native view.
|
void |
loadAd()
Request the Criteo SDK for a native ad matching the given
NativeAdUnit. |
void |
loadAd(Bid bid) |
static void |
setImageLoader(ImageLoader imageLoader)
Inject a custom
ImageLoader for native ads produced by all loader. |
public CriteoNativeLoader(@NonNull
com.criteo.publisher.model.NativeAdUnit adUnit,
@NonNull
CriteoNativeAdListener listener,
@NonNull
CriteoNativeRenderer renderer)
public static void setImageLoader(@NonNull
ImageLoader imageLoader)
ImageLoader for native ads produced by all loader.
When setting media in view,
if the media is an image, then the given image loader is used to load and display the media.
This lets you inject your own loading mechanism so that the application has exactly the same
image loading experience for both content and native ads.
If not set, a default implementation is used instead.
Warning: You should call this method after the SDK is initialized
imageLoader - custom global image loader to set@NonNull
public android.view.View createEmptyNativeView(@NonNull
android.content.Context context,
@Nullable
android.view.ViewGroup parent)
You can add it to your view hierarchy, but it is empty and not rendered yet. To render it, you
need to get a CriteoNativeAd by requesting an ad (see loadAd() or loadAd(Bid)), then you can call CriteoNativeAd.renderNativeView(View).
Note that you are expected to use this method if you're using a recycler view. So you can
create your views in onCreateViewHolder, and render them separately in
onBindViewHolder.
Note that parent is given so that inflated views are setup with the ViewGroup.LayoutParams corresponding to their parent. See CriteoNativeRenderer for more information.
context - android contextparent - optional parent to get layout params frompublic void loadAd()
NativeAdUnit.
This method returns immediately. If an ad is available, you will be notified by the CriteoNativeAdListener.onAdReceived(CriteoNativeAd) callback. If no ad is available, you will
be notified by the CriteoNativeAdListener.onAdFailedToReceive(CriteoErrorCode)
callback.public void loadAd(@Nullable
Bid bid)