package Ġcom . br aze . advanced samples Ċ Ċ import Ġandroid . content . Context Ċ import Ġcom . app boy . App boy Ċ import Ġcom . app boy . models . cards . Banner Image Card Ċ import Ġcom . app boy . models . cards . Caption ed Image Card Ċ import Ġcom . app boy . models . cards . Card Ċ import Ġcom . app boy . models . cards . Short News Card Ċ import Ġcom . br aze . advanced samples . content cards . Content Card able Observer Ċ import Ġcom . br aze . advanced samples . content cards . model .* Ċ import Ġcom . br aze . advanced samples . content cards . model . Content Card able . Keys . card Description Ċ import Ġcom . br aze . advanced samples . content cards . model . Content Card able . Keys . class Type Ċ import Ġcom . br aze . advanced samples . content cards . model . Content Card able . Keys . created Ċ import Ġcom . br aze . advanced samples . content cards . model . Content Card able . Keys . dismiss able Ċ import Ġcom . br aze . advanced samples . content cards . model . Content Card able . Keys . extras Ċ import Ġcom . br aze . advanced samples . content cards . model . Content Card able . Keys . html Ċ import Ġcom . br aze . advanced samples . content cards . model . Content Card able . Keys . id String Ċ import Ġcom . br aze . advanced samples . content cards . model . Content Card able . Keys . image Ċ import Ġcom . br aze . advanced samples . content cards . model . Content Card able . Keys . message Header Ċ import Ġcom . br aze . advanced samples . content cards . model . Content Card able . Keys . message Title Ċ import Ġcom . br aze . advanced samples . content cards . model . Content Card able . Keys . title Ċ import Ġcom . br aze . advanced samples . content cards . model . Content Card able . Keys . url String Ċ import Ġcom . br aze . advanced samples . in app . slide up . Custom In App Message View Wrapper Factory Ċ import Ġcom . br aze . events . Content Cards Updated Event Ċ import Ġcom . br aze . ui . in app message . Br aze In App Message Manager ĊĊ Ċ class ĠBr aze Manager Ġprivate Ġconstructor ( private Ġval Ġcontext : ĠContext ) Ġ{ ĊĊĠĠĠ Ġprivate Ġvar Ġregistered For Content Card Updates : ĠBoolean Ġ= Ġfalse ĊĠĠĠ Ġprivate Ġval Ġcontent Card able Observer s Ġ= Ġmutable Set Of < Content Card able Observer >() ĊĠĠĠ Ġprivate Ġvar Ġcard List : ĠList < Card > Ġ= ĠlistOf () ĊĊĠĠĠ Ġfun Ġuser Login ( username : String ){ ĊĠĠĠĠĠĠĠ ĠApp boy . getInstance ( context ). change User ( username ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġregister For Content Card Updates (){ ĊĠĠĠĠĠĠĠ Ġif Ġ(! registered For Content Card Updates ){ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠApp boy . getInstance ( context ). subscribe To Content Cards Updates ( this :: on Content Cards Updated ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġregistered For Content Card Updates Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġregister Content Card able Observer ( observer : ĠContent Card able Observer ){ ĊĠĠĠĠĠĠĠ Ġregister For Content Card Updates () ĊĠĠĠĠĠĠĠ Ġcontent Card able Observer s . add ( observer ) ĊĠĠĠĠĠĠĠ Ġrequest Content Card Update () ĊĠĠĠĠĠĠĠ Ġif Ġ( card List . isNotEmpty ()){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġobserver . on Content Cards Changed ( map Cards To Card ables ( card List )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġunregister Content Card able Observer ( observer : ĠContent Card able Observer ){ ĊĠĠĠĠĠĠĠ Ġcontent Card able Observer s . remove ( observer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġconfigure Custom In App Message View Factory (){ ĊĠĠĠĠĠĠĠ ĠBr aze In App Message Manager . getInstance (). set Custom In App Message View Wrapper Factory ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCustom In App Message View Wrapper Factory () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġrequest Content Card Update (){ ĊĠĠĠĠĠĠĠ ĠApp boy . getInstance ( context ). request Content Cards Refresh ( false ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġmap Cards To Card ables ( cards : ĠList < Card >): List < Content Card able >{ ĊĠĠĠĠĠĠĠ Ġreturn Ġcards . map NotNull Ġ{ Ġcard Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmetadata Ġ= ĠHashMap < String , ĠAny >() ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmetadata [ id String ] Ġ= Ġcard . id ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmetadata [ created ] Ġ= Ġcard . created ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmetadata [ dismiss able ] Ġ= Ġcard . is Dismiss ible ByUser ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġcard . url ?. let Ġ{ Ġmetadata [ url String ] Ġ= Ġit Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcard . extras ?. let Ġ{ Ġmetadata [ extras ] Ġ= Ġit Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcard . extras ?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmetadata [ class Type ] Ġ= Ġit [ class Type ] Ġas ĠString ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġit [ html ]?. let Ġ{ Ġh Ġ-> Ġmetadata [ html ] Ġ= Ġh Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġit [ message Header ]?. let Ġ{ Ġs Ġ-> Ġmetadata [ message Header ] Ġ= Ġs Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġit [ message Title ]?. let Ġ{ Ġs Ġ-> Ġmetadata [ message Title ] Ġ= Ġ Ġs Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhen Ġ( card ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠBanner Image Card Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmetadata [ image ] Ġ= Ġcard . imageUrl ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCaption ed Image Card Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmetadata [ message Title ] Ġ= Ġcard . title ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmetadata [ image ] Ġ= Ġcard . imageUrl ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmetadata [ card Description ] Ġ= Ġcard . description ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠShort News Card Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmetadata [ title ] Ġ= Ġcard . title ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmetadata [ card Description ] Ġ= Ġcard . description ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmetadata [ image ] Ġ= Ġcard . imageUrl ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Content Card able ( metadata , ĠContent Card Class . value From ( metadata [ class Type ] Ġas ? ĠString )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġon Content Cards Updated ( event : ĠContent Cards Updated Event ){ ĊĠĠĠĠĠĠĠ Ġthis . card List Ġ= Ġevent . all Cards ĊĠĠĠĠĠĠĠ Ġval Ġcard ables Ġ= Ġmap Cards To Card ables ( event . all Cards ) ĊĠĠĠĠĠĠĠ Ġcontent Card able Observer s . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . on Content Cards Changed ( card ables ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Content Card able ( metadata : ĠMap < String , ĠAny >, Ġtype : ĠContent Card Class ?): ĠContent Card able ? { ĊĠĠĠĠĠĠĠ Ġreturn Ġwhen ( type ){ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠContent Card Class . AD Ġ-> ĠAd ( metadata ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠContent Card Class . MESSAGE _ WEB _ VIEW Ġ-> ĠWebView Message ( metadata ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠContent Card Class . MESSAGE _ FULL _ PAGE Ġ-> ĠFull Page Message ( metadata ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠContent Card Class . ITEM _ GROUP Ġ-> ĠGroup ( metadata ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠContent Card Class . ITEM _ TILE Ġ-> ĠTile ( metadata ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠContent Card Class . CO UP ON Ġ-> ĠCo upon ( metadata ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġnull ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġlog Custom Event ( evt : String ){ ĊĠĠĠĠĠĠĠ ĠApp boy . getInstance ( context ). log Custom Event ( evt ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġlog Content Card Clicked ( id String : ĠString ?) Ġ{ ĊĠĠĠĠĠĠĠ ĠgetContent Card ( id String )?. log Click () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġlog Content Card Imp ression ( id String : ĠString ?) Ġ{ ĊĠĠĠĠĠĠĠ ĠgetContent Card ( id String )?. log Imp ression () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġlog Content Card Dis missed ( id String : ĠString ?) Ġ{ ĊĠĠĠĠĠĠĠ ĠgetContent Card ( id String )?. setIs Dis missed ( true ) ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġprivate Ġfun ĠgetContent Card ( id String : ĠString ?): ĠCard ? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġcard List . find Ġ{ Ġit . id Ġ== Ġid String Ġ}. take If Ġ{ Ġit Ġ!= Ġnull Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ: ĠSingleton Holder < Br aze Manager , ĠContext >( :: Br aze Manager ) Ċ Ċ }