public class NativeAdFactory extends Object implements INativeAdFactory
Constructor and Description |
---|
NativeAdFactory(Context context,
String adUnitId,
INativeAdArbiter arbiteur)
Creates a new native ad factory.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Cleans up any used resources
|
NativeAd |
getAd(int position,
int itemCount)
Returns an ad if there are ads and one should be shown to the user.
|
AdListener |
getAdListener()
Returns the event listener.
|
int |
getCount(int itemCount)
Gets the total count of items and ads.
|
void |
init(int itemCount)
Initializes the ad factory by pre-loading ads.
|
boolean |
isAdShownAt(int position)
Returns whether an ad was rendered at the specified position (including previous rendered ads).
|
void |
setAdListener(AdListener adListener)
Sets the listener for events related to loading native ads.
|
boolean |
shouldShowAd(int position,
int itemCount)
Returns whether an ad should to shown to the user at the specified position considering there
will the specified total number of items.
|
int |
totalAdsShown()
Return the total number of ads that have been rendered thus far.
|
public NativeAdFactory(Context context, String adUnitId, INativeAdArbiter arbiteur)
context
- contextadUnitId
- ad unit IDarbiteur
- ad arbiteur that decides when to show adsIllegalArgumentException
- if adUnitId
is null
public void init(int itemCount)
itemCount
- expected total number of items (excluding ads)public void setAdListener(AdListener adListener)
INativeAdFactory
setAdListener
in interface INativeAdFactory
adListener
- listenerpublic AdListener getAdListener()
INativeAdFactory
getAdListener
in interface INativeAdFactory
public boolean shouldShowAd(int position, int itemCount)
INativeAdFactory
shouldShowAd
in interface INativeAdFactory
position
- current position (including ads)itemCount
- total number of items (excluding ads)public NativeAd getAd(int position, int itemCount)
INativeAdFactory
getAd
in interface INativeAdFactory
position
- current position (including ads)itemCount
- total number of items (excluding ads)public boolean isAdShownAt(int position)
INativeAdFactory
isAdShownAt
in interface INativeAdFactory
position
- position include adspublic int totalAdsShown()
INativeAdFactory
totalAdsShown
in interface INativeAdFactory
public int getCount(int itemCount)
INativeAdFactory
getCount
in interface INativeAdFactory
itemCount
- total number of items (excluding ads)public void destroy()
INativeAdFactory
destroy
in interface INativeAdFactory