-
@MainThread() public interface AdRenderer
Produces an adapter-owned View for rendering a single ad.
Attached optionally to ad.elo.androidsdk.EloAd by adapters whose networks require SDK-owned view registration to count impressions and clicks (AdMob, Meta Audience Network). When a renderer is present, the SDK's Compose ad views embed the returned view via
AndroidView { ... }instead of rendering Elo-styled chrome.Mirrors iOS
AdRenderer. Methods are called from the main thread; the MainThread annotation propagates to all members for lint enforcement.
-
-
Method Summary
Modifier and Type Method Description abstract ViewmakeView(Context context)Build a fresh View containing chrome and registered asset slots. Unitupdate(View view)Bind ad data into a previously-built view. Unitrelease(View view)Release view-owned resources tied to view. IntegergetMinimumDisplayHeightDp()-
-
Method Detail
-
makeView
abstract View makeView(Context context)
Build a fresh View containing chrome and registered asset slots. Asset binding belongs in update so it can run separately from construction.
Called once per Compose mount — every host (chat surface, list cell) gets its own View. Sharing one View across hosts breaks Android's "one parent per view" invariant.
-
update
Unit update(View view)
Bind ad data into a previously-built view. Runs on every recomposition with new inputs, including the first one immediately after makeView; Compose does not guarantee the view has been measured or laid out by then. For assets that need real bounds (e.g. AdMob's
MediaView), defer binding inside update (e.g.view.doOnLayout { … }) or rely on the underlying SDK's own deferred binding.Default is a no-op for renderers that don't need per-update binding.
-
release
Unit release(View view)
Release view-owned resources tied to view. Called when the embedding composable leaves composition (or before the view is discarded on ad swap), via Compose's
AndroidView(onRelease = ...)callback.Do not destroy ad-owned network objects here if the same AdRenderer may render again after a transient unmount. Put that cleanup behind
EloAd.releaseResources()instead.Default is a no-op for renderers without view cleanup needs.
-
getMinimumDisplayHeightDp
Integer getMinimumDisplayHeightDp()
-
-
-
-