Android Verizon Ads SDK Standard Edition Documentation  1.14
Classes | Public Member Functions | Static Public Member Functions | List of all members
NativeAdFactory Class Reference

NativeAdFactory is a factory class that handles loading and caching of NativeAd placements. More...

Classes

interface  NativeAdFactoryListener
 Interface for receiving notifications from the NativeAdFactory. More...
 

Public Member Functions

 NativeAdFactory (final Context context, final String placementId, final String[] adTypes, final NativeAdFactoryListener adFactoryListener)
 Factory method for creating NativeAd objects. More...
 
void abortLoad ()
 Aborts any load requests that are still active.
 
void destroy ()
 Frees the internal resources held by the factory. More...
 
String getPlacementId ()
 Get the placementId for the NativeAdFactory. More...
 
RequestMetadata getRequestMetadata ()
 Provides access to the RequestMetadata that has been set for the NativeAdFactory. More...
 
void load (final Bid bid, final NativeAdListener nativeAdListener)
 Loads the NativeAd for the provided bid. More...
 
void load (final NativeAdListener nativeAdListener)
 Requests a new NativeAd. More...
 
NativeAd loadAdFromCache (final NativeAdListener nativeAdListener)
 Attempts to load a NativeAd from the cache. More...
 
void loadWithoutAssets (final Bid bid, final NativeAdListener nativeAdListener)
 Loads the NativeAd for the provided bid. More...
 
void loadWithoutAssets (final NativeAdListener nativeAdListener)
 Requests a new NativeAd. More...
 
void prefetch ()
 Initializes a cache replenishment request. More...
 
void setCacheReplenishmentThresholdOverride (final int cacheReplenishmentThresholdOverride)
 Sets the cache replenishment threshold. More...
 
void setListener (final NativeAdFactoryListener adFactoryListener)
 Set the NativeAdFactoryListener to receive ad factory event callbacks. More...
 
void setRequestMetaData (final RequestMetadata requestMetadata)
 Sets a RequestMetadata object that overrides global RequestMetadata for the NativeAdFactory’s ad requests. More...
 

Static Public Member Functions

static void requestBid (final Context context, final String placementId, final String[] adTypes, final RequestMetadata requestMetadata, final BidRequestListener bidRequestListener)
 Requests a bid for the opportunity to win the NativeAd impression. More...
 

Detailed Description

NativeAdFactory is a factory class that handles loading and caching of NativeAd placements.

It uses the NativeAdFactoryListener interface to provide notifications about NativeAd creation.

Constructor & Destructor Documentation

◆ NativeAdFactory()

NativeAdFactory ( final Context  context,
final String  placementId,
final String[]  adTypes,
final NativeAdFactoryListener  adFactoryListener 
)

Factory method for creating NativeAd objects.

Use this to set the placementId and listener for NativeAds that the NativeAdFactory will create.

Parameters
contextthe context in which the NativeAds will be loaded
placementIdplacementId that will be set for all NativeAds that the NativeAdFactory creates
adTypesarray of requested native types
adFactoryListenerthe NativeAdFactoryListener that will receive ad factory events for the NativeAdFactory

Member Function Documentation

◆ destroy()

void destroy ( )

Frees the internal resources held by the factory.

The instance cannot be used after this method is called.

◆ getPlacementId()

String getPlacementId ( )

Get the placementId for the NativeAdFactory.

Returns
the placementId for the NativeAdFactory

◆ getRequestMetadata()

RequestMetadata getRequestMetadata ( )

Provides access to the RequestMetadata that has been set for the NativeAdFactory.

Returns
the RequestMetadata set for the NativeAdFactory

◆ load() [1/2]

void load ( final Bid  bid,
final NativeAdListener  nativeAdListener 
)

Loads the NativeAd for the provided bid.

Parameters
bidthe Bid that will be loaded
nativeAdListenerthe NativeAd.NativeAdListener that will receive ad events for the NativeAd

◆ load() [2/2]

void load ( final NativeAdListener  nativeAdListener)

Requests a new NativeAd.

Parameters
nativeAdListenerthe NativeAd.NativeAdListener that will receive ad events for the NativeAd

◆ loadAdFromCache()

NativeAd loadAdFromCache ( final NativeAdListener  nativeAdListener)

Attempts to load a NativeAd from the cache.

If the cache is empty, null is returned.

Parameters
nativeAdListenerthe NativeAd.NativeAdListener that will receive ad events for the NativeAd
Returns
a NativeAd from the cache or null if the cache is empty

◆ loadWithoutAssets() [1/2]

void loadWithoutAssets ( final Bid  bid,
final NativeAdListener  nativeAdListener 
)

Loads the NativeAd for the provided bid.

Assets (images and videos) will not be loaded.

Parameters
bidthe Bid that will be loaded
nativeAdListenerthe NativeAd.NativeAdListener that will receive ad events for the NativeAd

◆ loadWithoutAssets() [2/2]

void loadWithoutAssets ( final NativeAdListener  nativeAdListener)

Requests a new NativeAd.

Assets (images and videos) will not be loaded.

Parameters
nativeAdListenerthe NativeAd.NativeAdListener that will receive ad events for the NativeAd

◆ prefetch()

void prefetch ( )

Initializes a cache replenishment request.

Note that if a request is already in progress or the cache is not below the replenishment threshold, no request will be made.

◆ requestBid()

static void requestBid ( final Context  context,
final String  placementId,
final String[]  adTypes,
final RequestMetadata  requestMetadata,
final BidRequestListener  bidRequestListener 
)
static

Requests a bid for the opportunity to win the NativeAd impression.

Parameters
contextthe context in which the NativeAds will be loaded
placementIdplacementId that will be set for all NativeAds that the NativeAdFactory creates
adTypesarray of requested native types
requestMetadatathe RequestMetadata to use for ad requests
bidRequestListenerthe BidRequestListener that will receive bid request events

◆ setCacheReplenishmentThresholdOverride()

void setCacheReplenishmentThresholdOverride ( final int  cacheReplenishmentThresholdOverride)

Sets the cache replenishment threshold.

If the resulting cache size after an ad is loaded from the cache is less than or equal this value the factory will attempt to replenish the cache.

Parameters
cacheReplenishmentThresholdOverridethe cache size threshold for triggering a replenishment

◆ setListener()

void setListener ( final NativeAdFactoryListener  adFactoryListener)

Set the NativeAdFactoryListener to receive ad factory event callbacks.

Parameters
adFactoryListenerthe NativeAdFactoryListener to set. Called when ad factory events occur.

◆ setRequestMetaData()

void setRequestMetaData ( final RequestMetadata  requestMetadata)

Sets a RequestMetadata object that overrides global RequestMetadata for the NativeAdFactory’s ad requests.

Parameters
requestMetadatathe RequestMetadata to use for ad requests