Triton Mobile SDK for Android
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
com.tritondigital.ads.BannerView Class Reference

The View to display banner ads. More...

Inheritance diagram for com.tritondigital.ads.BannerView:
com.tritondigital.ads.SyncBannerView

Classes

interface  BannerListener
 A listener for receiving BannerView notifications. More...
 

Public Member Functions

 BannerView (Context context)
 Constructor.
 
 BannerView (Context context, AttributeSet attrs)
 Constructor.
 
 BannerView (Context context, AttributeSet attrs, int defStyle)
 Constructor.
 
void clearBanner ()
 Clears the current ad but keep the View in order to reuse it later. More...
 
int getBannerFallbackHeight ()
 Returns the banner's fallback height in density-independent pixels.
 
int getBannerFallbackWidth ()
 Returns the banner's fallback width in density-independent pixels.
 
int getBannerHeight ()
 Returns the banner's height in density-independent pixels.
 
int getBannerWidth ()
 Returns the banner's width in density-independent pixels.
 
Point getBestBannerSize (Bundle ad, int containerWidth, int containerHeight)
 Find the best banner size from an ad bundle which fits a layout container. More...
 
BannerListener getListener ()
 Returns the banner listener.
 
boolean isBannerLoaded ()
 Returns true if the an ad is loaded.
 
void onPause ()
 Pauses any extra processing associated with this BannerView. More...
 
void onResume ()
 Resumes an BannerView after a previous call to pause(). More...
 
void release ()
 Destroys the internal state of this BannerView. More...
 
void setBannerSize (int width, int height)
 
void setBannerSize (int width, int height, int fallbackWidth, int fallbackHeight)
 Sets the ad size in density-independent pixels. More...
 
void setListener (BannerListener listener)
 Sets the banner listener.
 
void showAd (Bundle ad)
 Show an ad. More...
 

Static Public Member Functions

static String debugErrorToStr (int errorCode)
 Converts the error codes to a string. More...
 

Static Public Attributes

static final int ERROR_BANNER_SIZE_NOT_SET = 8012
 setBannerSize(int, int) must be called before loading an ad
 
static final int ERROR_LOAD_AFTER_RELEASE = 8006
 Trying to load an ad after release()
 
static final int ERROR_NETWORK_NOT_AVAILABLE = AdLoader.ERROR_NETWORK_NOT_AVAILABLE
 Network not available.
 
static final int ERROR_NO_BANNER_RIGHT_SIZE = 8011
 The loaded ad doesn't have a banner of the right size.
 
static final int ERROR_NO_BANNERS = 8010
 The loaded ad doesn't have any banner.
 
static final int ERROR_NO_INVENTORY = AdLoader.ERROR_NO_INVENTORY
 No ad available.
 
static final int ERROR_TIMEOUT = 8013
 The maximum time has been reached.
 
static final int ERROR_UNKNOWN = AdLoader.ERROR_UNKNOWN
 Unspecified error.
 
static final int ERROR_UNKNOWN_HOST = AdLoader.ERROR_UNKNOWN_HOST
 Unknown host.
 

Detailed Description

The View to display banner ads.

The size must be set prior to calling showAd(Bundle).

Ad Size
The ad size must be set prior to calling showAd(Bundle). The ad size and the View size are not the same thing. For example, a 320x50 ad can be loaded in a WRAP_CONTENT view.
Fallback Size
A fallback size can be set in case no ad is available for the main size. This feature was added in order to easily support 320x50 and 300x50 in the same view.

Member Function Documentation

◆ clearBanner()

void com.tritondigital.ads.BannerView.clearBanner ( )

Clears the current ad but keep the View in order to reuse it later.

This method is usually called at the end of an audio ad with a sync banner.

◆ debugErrorToStr()

static String com.tritondigital.ads.BannerView.debugErrorToStr ( int  errorCode)
static

Converts the error codes to a string.

Note
Only use for debugging purpose.

◆ getBestBannerSize()

Point com.tritondigital.ads.BannerView.getBestBannerSize ( Bundle  ad,
int  containerWidth,
int  containerHeight 
)

Find the best banner size from an ad bundle which fits a layout container.

It returns null if no size fits the container

Parameters
adThe Ad bundle with the banners to search for
containerWidthThe container width in dp
containerHeightThe container height in dp
Returns
a Point with Width and Height or null if no size fits the container

◆ onPause()

void com.tritondigital.ads.BannerView.onPause ( )

Pauses any extra processing associated with this BannerView.

This method should be called in the parent Activity.onPause() method.

See also
http://developer.android.com/reference/android/webkit/WebView.html#onPause()

◆ onResume()

void com.tritondigital.ads.BannerView.onResume ( )

Resumes an BannerView after a previous call to pause().

This method should be called in the parent Activity.onResume() method.

See also
http://developer.android.com/reference/android/webkit/WebView.html#onResume()

◆ release()

void com.tritondigital.ads.BannerView.release ( )

Destroys the internal state of this BannerView.

This method should be called after this BannerView has been removed from the view system. No other methods should be called this.

◆ setBannerSize() [1/2]

void com.tritondigital.ads.BannerView.setBannerSize ( int  width,
int  height 
)

◆ setBannerSize() [2/2]

void com.tritondigital.ads.BannerView.setBannerSize ( int  width,
int  height,
int  fallbackWidth,
int  fallbackHeight 
)

Sets the ad size in density-independent pixels.

The size change will be effective only on the next ad display. The fallback values will be used if no banner is found with the main size.

◆ showAd()

void com.tritondigital.ads.BannerView.showAd ( Bundle  ad)

Show an ad.

This view takes care of taking the right banner from the ad bundle.

Parameters
adThe ad to load.