package Ġga . nk 2 ish ere . dev . fl uff yp at rol . ui . show pet Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . View Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . recyclerview . widget . Grid LayoutManager Ċ import Ġcom . are l lo mobile . mvp . presenter . Inject Presenter Ċ import Ġcom . are l lo mobile . mvp . presenter . Provide Presenter Ċ import Ġcom . blue lin el abs . cond uctor . Router Transaction Ċ import Ġcom . blue lin el abs . cond uctor . change handler . Fade Change Handler Ċ import Ġcom . x wr ay . group ie . Group Adapter Ċ import Ġcom . x wr ay . group ie . ViewHolder Ċ import Ġga . nk 2 ish ere . dev . base . Base Controller Ċ import Ġga . nk 2 ish ere . dev . base . Global Event Ċ import Ġga . nk 2 ish ere . dev . base . M vi View Ċ import Ġga . nk 2 ish ere . dev . fl uff yp at rol . R Ċ import Ġga . nk 2 ish ere . dev . fl uff yp at rol . common . data . Dog Ċ import Ġga . nk 2 ish ere . dev . fl uff yp at rol . common . data . Health Ċ import Ġga . nk 2 ish ere . dev . fl uff yp at rol . common . inter actors . Health Interactor Ċ import Ġga . nk 2 ish ere . dev . fl uff yp at rol . ui . add health . Add Health Controller Ċ import Ġga . nk 2 ish ere . dev . fl uff yp at rol . ui . add health . Add Health View Notify Health Saved Action Ċ import Ġga . nk 2 ish ere . dev . fl uff yp at rol . ui . add health . Add Health View Notify Health Saved Global Event Ċ import Ġga . nk 2 ish ere . dev . fl uff yp at rol . ui . add pet . Add Pet Presenter Ċ import Ġga . nk 2 ish ere . dev . utils . round Ċ import Ġkotlinx . android . synt hetic . main . show _ pet . view .* Ċ import Ġorg . k oin . standalone . K oin Component Ċ import Ġorg . k oin . standalone . inject Ċ import Ġtim ber . log . Tim ber Ċ Ċ class ĠShow Pet Controller ( args : ĠBundle , Ġprivate Ġval Ġpet : ĠDog ? Ġ= Ġnull ): ĠBaseController ( args ), ĠShow Pet View , ĠShow Pet View PM Renderer Ġ{ ĊĠĠĠ Ġconstructor ( args : ĠBundle ): Ġthis ( args , Ġnull ) ĊĊĠĠĠ Ġprivate Ġval Ġrender Dispatcher Ġ= ĠShow Pet View PMD iff Dispatcher . Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. target ( this ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠ Ġprivate Ġvar Ġprevious Show Pet View PM : ĠShow Pet View PM ? Ġ= Ġnull ĊĠĠĠ Ġprivate Ġval Ġhealth ListAdapter Ġ= ĠGroup Adapter < ViewHolder >() ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġcreate ( pet : ĠDog ? Ġ= Ġnull ) Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠShow Pet Controller ( Bundle (), Ġpet ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġrender Current Pet ( current Pet : ĠShow Pet View PM . Pet State ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġview ?. name ?. text Ġ= Ġcurrent Pet ?. name ĊĠĠĠĠĠĠĠ Ġview ?. type ?. text Ġ= Ġcurrent Pet ?. type ?. pretty Name ĊĠĠĠĠĠĠĠ Ġview ?. age ?. text Ġ= Ġcurrent Pet ?. age . toString () ĊĠĠĠĠĠĠĠ Ġview ?. gender ?. setImage Drawable ( resources ?. get Drawable ( when Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcurrent Pet ?. gender Ġ== ĠDog . Gender . M Ġ-> ĠR . drawable . fp _ male ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcurrent Pet ?. gender Ġ== ĠDog . Gender . F Ġ-> ĠR . drawable . fp _ female ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> ĠR . drawable . fp _ no _ photo ĊĠĠĠĠĠĠĠ Ġ})) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġrender Current Health ( current Health : ĠHealth ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġview ?. current Health ?. text Ġ= Ġcurrent Health ?. coefficient ?. times ( 1 0 0 )?. round ( 2 )?. toString () Ġ?: Ġ" Ð½ ÐµÑĤ " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġrender Health s ( health s : ĠList < Health >) Ġ{ ĊĠĠĠĠĠĠĠ Ġhealth s . forEach Ġ{ Ġview ?. health Graph ?. add Value ( it . coefficient . times ( 1 0 0 ). toFloat ()) Ġ} ĊĠĠĠĠĠĠĠ Ġapplication Context ?. let Ġ{ Ġcontext Ġ-> Ġhealth ListAdapter . update ( health s . map Ġ{ ĠHealth Item ( context , Ġit ) Ġ}) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġupdate P MA ction ( action : ĠShow Pet View Update P MA ction ) Ġ{ ĊĠĠĠĠĠĠĠ Ġrender Dispatcher . dispatch ( action . pm , Ġprevious Show Pet View PM ) ĊĠĠĠĠĠĠĠ Ġprevious Show Pet View PM Ġ= Ġaction . pm ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġshow Add Health Action ( action : ĠShow Pet View Show Add Health Action ) Ġ{ ĊĠĠĠĠĠĠĠ Ġrouter . push Controller ( Router Transaction . with ( Add Health Controller . create ( pet )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. push Change Handler ( Fade Change Handler ( false )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. pop Change Handler ( Fade Change Handler ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Inject Presenter Ġlateinit Ġvar Ġpresenter : ĠShow Pet Presenter ĊĠĠĠ Ġ@ Provide Presenter Ġfun Ġprovide Presenter (): ĠShow Pet Presenter Ġ= ĠShow Pet Presenter ( pet ) ĊĊĠĠĠ Ġoverride Ġfun Ġget Layout Id (): ĠInt Ġ= ĠR . layout . show _ pet ĊĊĠĠĠ Ġoverride Ġfun Ġinit View ( view : ĠView ) Ġ{ ĊĠĠĠĠĠĠĠ Ġview . health List . layout Manager Ġ= ĠGrid LayoutManager ( application Context , Ġ 2 , ĠGrid LayoutManager . VERTICAL , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġview . health List . adapter Ġ= Ġhealth ListAdapter ĊĠĠĠĠĠĠĠ Ġview . add Health . setOnClickListener Ġ{ Ġpresenter . handle View Event ( Show Pet View Add Health Button Clicked Event ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġapply Action ( action : ĠShow Pet View Action ) Ġ{ Ġwhen ( action ) Ġ{ ĊĠĠĠĠĠĠĠ Ġis ĠShow Pet View Update P MA ction Ġ-> Ġupdate P MA ction ( action ) ĊĠĠĠ Ġ} Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġapply Action With Skip ( action : ĠShow Pet View Action ) Ġ{ Ġwhen ( action ) Ġ{ ĊĠĠĠĠĠĠĠ Ġis ĠShow Pet View Show Add Health Action Ġ-> Ġshow Add Health Action ( action ) ĊĠĠĠ Ġ} Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġapply Global Event ( event : ĠGlobal Event ) Ġ{ Ġwhen ( event ) Ġ{ ĊĠĠĠĠĠĠĠ Ġis ĠAdd Health View Notify Health Saved Global Event Ġ-> Ġpresenter . handle View Event ( Show Pet View Health Saved Event ()) ĊĠĠĠ Ġ} Ġ} Ċ }