package Ġcom . if m vo . together ad . baidu Ċ Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . ImageView Ċ import Ġandroid . widget . LinearLayout Ċ import Ġandroid . widget . TextView Ċ import Ġcom . baidu . mo bad . feeds . Native Response Ċ import Ġcom . if m vo . together ad . core . To gether Ad Ċ import Ġcom . if m vo . together ad . core . custom . flow . Base Native View Ċ import Ġcom . if m vo . together ad . core . listener . Native View Listener Ċ import Ġcom . if m vo . together ad . core . utils . Screen Util Ċ Ċ /** Ċ Ġ* ĠCreated Ġby ĠMat thew ĠChen Ġon Ġ 2 0 2 0 - 0 4 - 2 1 . Ċ Ġ*/ Ċ class ĠNative View B aid u Common Ġ: ĠBase Native View () Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġshow Native ( ad Provider Type : ĠString , Ġad Object : ĠAny , Ġcontainer : ĠViewGroup , Ġlistener : ĠNative View Listener ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( ad Object Ġ! is ĠNative Response ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġroot View Ġ= ĠView . inflate ( container . context , ĠR . layout . layout _ native _ view _ baidu _ common , Ġcontainer ) ĊĊĠĠĠĠĠĠĠ Ġval Ġm Img Post er Ġ= Ġroot View . findViewById < ImageView >( R . id . img _ poster ) ĊĠĠĠĠĠĠĠ Ġval Ġm Ll Parent Ġ= Ġroot View . findViewById < LinearLayout >( R . id . ll _ parent ) ĊĠĠĠĠĠĠĠ Ġval Ġm Tv Title Ġ= Ġroot View . findViewById < TextView >( R . id . tv _ title ) ĊĠĠĠĠĠĠĠ Ġval Ġm Tv Desc Ġ= Ġroot View . findViewById < TextView >( R . id . tv _ desc ) Ċ // ĠĠĠĠĠĠĠ Ġval Ġm Ad Logo View Ġ= Ġroot View . findViewById < Ad Logo View >( R . id . ad _ logo _ view ) ĊĠĠĠĠĠĠĠ Ġval Ġlayout Params Ġ= Ġm Img Post er ?. layout Params ĊĠĠĠĠĠĠĠ Ġlayout Params ?. height Ġ= ĠScreen Util . getDisplay Metrics Width ( container . context ) Ġ* Ġ 9 Ġ/ Ġ 1 6 ĊĊĠĠĠĠĠĠĠ Ġm Tv Title ?. text Ġ= Ġad Object . title ĊĠĠĠĠĠĠĠ Ġm Tv Desc ?. text Ġ= Ġad Object . desc Ċ // ĠĠĠĠĠĠĠ Ġm Ad Logo View . set Ad Logo Type ( Ad Name Type . BA ID U , Ġad Object ) ĊĠĠĠĠĠĠĠ ĠTo gether Ad . m Image Loader ?. load Image ( container . context , Ġm Img Post er , Ġad Object . imageUrl ) ĊĠĠĠĠĠĠĠ Ġlistener ?. on Ad Ex posed ( ad Provider Type ) ĊĠĠĠĠĠĠĠ Ġad Object . record Imp ression ( m Ll Parent ) ĊĠĠĠĠĠĠĠ Ġm Ll Parent ?. setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġad Object . handle Click ( it ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġlistener ?. on Ad Clicked ( ad Provider Type ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ }