Skip to content

AdRenderer

Anirudh Ramanan edited this page Jan 22, 2020 · 1 revision

The AdRenderer houses the logic for rendering the UI components on the top of the ad. The AdRenderer implements the AdPlayerProvider which provides the player interface. The player interface is implemented by the client which does the actual playback of the ad.

The DefaultAdRenderer provides a default implementation of the AdRenderer. It follows a builder pattern which enables the client to set player, view group container (to which the ad ui is attached), rendering settings and ad view binder. The ad view binder takes in the layout id to inflate along with other view id's such as for skip ad view, learn more view etc. Passing AdViewBinder is optional, the library provides a default layout for the ad overlay.

Components:

  • AdPlayerProvider: provides the player interface.

  • AdPlayer: The player interface is implemented by the client. The ad manager implements the AdPlayerCallback and uses the player instance for loading, playing and stopping the ad.

  • RenderingSettings: to provide rendering config such as pre-load time and more.

  • RendererViewCallback: The AdManager registers itself as a view callback to the ad renderer. The registerer gets notified on click of the views such as skip ad, view click, learn more click etc.

API's:

  • getRenderingSettings(): RenderingSettings - Returns the rendering setting such as pre-loading time etc.

  • createView() - Inflates a new view for the given layout id and attaches it to the view group

  • renderView(adElement: AdElement) - renders the view for the given ad element. All the logic of showing skip ad or not, and other UI element is handled by this method.

  • removeView() - removes the view from the view group

  • destroy() - clean up the ad renderer

  • registerViewCallbacks(callback: RendererViewCallback) - register the view callback. All the registered view callbacks are notified on any action on the UI such as click etc. As of now, onSkipAdClick, onAdViewClick, onClickThoughClick is supported.

  • unregisterViewCallbacks(callback: RendererViewCallback) - unregister the previously registered callback.

Clone this wiki locally