package Ġcom . kot mob . ad mob lib . ui Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . graphics . Color Ċ import Ġandroid . net . Uri Ċ import Ġandroid . util . Attribute Set Ċ import Ġandroid . view . View Ċ import Ġcom . kot mob . ad mob lib . R Ċ import Ġandroid . widget .* Ċ import Ġcom . kot mob . ad mob lib . exceptions . App Url Required Exception Ċ import Ġcom . kot mob . ad mob lib . models . Native Ad Size Ċ import Ġkotlinx . android . synt hetic . main . offline _ native _ ad . view . ad _ app _ icon Ċ import Ġkotlinx . android . synt hetic . main . offline _ native _ ad . view . ad _ body Ċ import Ġkotlinx . android . synt hetic . main . offline _ native _ ad . view . ad _ call _ to _ action Ċ import Ġkotlinx . android . synt hetic . main . offline _ native _ ad . view . ad _ headline Ċ import Ġkotlinx . android . synt hetic . main . offline _ native _ ad . view . ad _ media Ċ import Ġkotlinx . android . synt hetic . main . offline _ native _ ad . view . ad _ parent _ view ĊĊ Ċ class ĠOff line Native Ad Ġ( context : ĠContext , Ġattrs : ĠAttributeSet ): ĠLinearLayout ( context , Ġattrs ){ ĊĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠ Ġinf late ( context Ġ, R . layout . offline _ native _ ad Ġ, Ġ Ġthis ) ĊĠĠĠĠĠĠ Ġval Ġattributes Ġ= Ġcontext . obtain Styled Attributes ( attrs Ġ, ĠR . style able . Offline Native Ad Ġ, Ġ 0 , 0 ) ĊĠĠĠĠĠĠ Ġval Ġbutton Shape Res Ġ= attributes . getResource Id ( R . style able . Offline Native Ad _ button _ shape Ġ, ĠR . drawable . rounded _ button _ bg ) ĊĠĠĠĠĠĠ Ġval Ġbutton TextColor Ġ= Ġattributes . getColor ( R . style able . Offline Native Ad _ button _ text _ color , Color . WHITE ) ĊĠĠĠĠĠĠ Ġval Ġtitle TextColor Ġ= Ġattributes . getColor ( R . style able . Offline Native Ad _ headline _ text _ color , Color . WHITE ) ĊĠĠĠĠĠĠ Ġval Ġbody TextColor Ġ= Ġattributes . getColor ( R . style able . Offline Native Ad _ body _ text _ color , Color . WHITE ) ĊĠĠĠĠĠĠ Ġval Ġis Body Ġ= Ġattributes . getBoolean ( R . style able . Offline Native Ad _ is _ body , Ġtrue ) ĊĊĠĠĠĠĠĠ Ġval Ġtitle Ġ= Ġattributes . getString ( R . style able . Offline Native Ad _ ad _ title ) ĊĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġattributes . getString ( R . style able . Offline Native Ad _ ad _ body ) ĊĠĠĠĠĠĠ Ġval Ġbutton Text Ġ= Ġattributes . getString ( R . style able . Offline Native Ad _ ad _ button _ text ) ĊĊĠĠĠĠĠĠ Ġval Ġicon Res Ġ= Ġattributes . getResource Id ( R . style able . Offline Native Ad _ ad _ icon Ġ, Ġ 0 ) ĊĠĠĠĠĠĠ Ġval Ġfeature Res Ġ= Ġattributes . getResource Id ( R . style able . Offline Native Ad _ ad _ feature _ src Ġ, Ġ 0 ) ĊĊĠĠĠĠĠĠ Ġval Ġurl Ġ= Ġattributes . getString ( R . style able . Offline Native Ad _ ad _ app _ url ) Ġ?: Ġthrow ĠApp Url Required Exception () ĊĊĠĠĠĠĠĠ Ġval Ġad Size Ġ= ĠNative Ad Size . values ()[ attributes . getInt ( R . style able . Offline Native Ad _ ad _ size , 0 )]; ĊĊ ĊĠĠĠĠĠĠ Ġad _ media . setImage Resource ( feature Res ) ĊĊĠĠĠĠĠĠ Ġad _ app _ icon . setImage Resource ( icon Res ) ĊĊĠĠĠĠĠĠ Ġad _ call _ to _ action . setBackground Resource ( button Shape Res ) ĊĠĠĠĠĠĠ Ġad _ call _ to _ action . setTextColor ( button TextColor ) ĊĠĠĠĠĠĠ Ġad _ call _ to _ action . text Ġ= Ġbutton Text ĊĊĠĠĠĠĠĠ Ġad _ headline . setTextColor ( title TextColor ) ĊĠĠĠĠĠĠ Ġad _ headline . text = Ġtitle ĊĊĠĠĠĠĠĠĠ Ġad _ body . visibility Ġ= Ġwhen ( is Body ){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtrue Ġ-> ĠView . VISIBLE ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfalse Ġ-> ĠView . GONE ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠ Ġad _ body . setTextColor ( body TextColor ) ĊĠĠĠĠĠĠ Ġad _ body . text = Ġbody ĊĊĠĠĠĠĠĠ Ġad _ call _ to _ action . setOnClickListener Ġ{ ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbrowser Intent Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠIntent ( Intent . ACTION _ VIEW , ĠUri . parse ( url )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontext . startActivity ( browser Intent ) ĊĊĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠ Ġval Ġheight Ġ= Ġwhen ( ad Size ){ ĊĠĠĠĠĠĠĠĠĠĠ ĠNative Ad Size . MEDIUM -> Ġresources . get Dimension Pixel Size ( R . dim en ._ 1 0 0 sdp ) ĊĠĠĠĠĠĠĠĠĠĠ ĠNative Ad Size . LARGE -> resources . get Dimension Pixel Size ( R . dim en ._ 1 5 0 sdp ) ĊĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠ Ġval Ġparams Ġ= Ġad _ parent _ view . get LayoutParams () ĊĠĠĠĠĠĠ Ġparams . height Ġ= Ġheight ĊĠĠĠĠĠĠ Ġad _ parent _ view . setLayout Params ( params ) ĊĠĠĠĠĠĠ Ġinvalidate () ĊĊĠĠĠĠĠĠ Ġattributes . recycle () ĊĠĠ Ġ} Ċ }