package Ġcom . github . vertex 1 3 . games list . presentation . games list Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . View Ċ import Ġandroid . widget . Toast Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġcom . github . vertex 1 3 . games list . R Ċ import Ġcom . github . vertex 1 3 . games list . domain . Game Ċ import Ġcom . github . vertex 1 3 . games list . presentation . common . Base Fragment Ċ import Ġcom . github . vertex 1 3 . games list . presentation . game details . Game Details Fragment Ċ import Ġkotlinx . android . synt hetic . main . fragment _ games _ list .* Ċ import Ġorg . k oin . android x . view model . ext . android . viewModel Ċ Ċ class ĠGames List Fragment Ġ: ĠBase Fragment () Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġnew Instance (): ĠGames List Fragment Ġ= ĠGames List Fragment () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġmodel : ĠGames List ViewModel Ġby ĠviewModel () ĊĊĠĠĠ Ġoverride Ġval Ġlayout Id : ĠInt Ġ= ĠR . layout . fragment _ games _ list ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġmodel . most Ant icip ated Category . observe ( view Lifecycle Owner , ĠObserver Ġ{ Ġdata Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġupdate Category View ( most Ant icip ated Games View , Ġdata ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġmodel . latest Category . observe ( view Lifecycle Owner , ĠObserver Ġ{ Ġdata Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġupdate Category View ( latest Games View , Ġdata ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġmodel . most R ated 2 0 2 0 Category . observe ( view Lifecycle Owner , ĠObserver Ġ{ Ġdata Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġupdate Category View ( most R ated Games View , Ġdata ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġmodel . loading Error . observe ( view Lifecycle Owner , ĠObserver Ġ{ Ġis Error Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( isError ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠToast . makeText ( context , ĠR . string . games _ list _ error , ĠToast . LENGTH _ SHORT ). show () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġmost Ant icip ated Games View . setOn Request More Games ( model :: load Most Ant icip ated Games ) ĊĠĠĠĠĠĠĠ Ġlatest Games View . setOn Request More Games ( model :: load Latest Games ) ĊĠĠĠĠĠĠĠ Ġmost R ated Games View . setOn Request More Games ( model :: load Most R ated 2 0 2 0 Games ) ĊĊĠĠĠĠĠĠĠ Ġmost Ant icip ated Games View . setOn Game Click (:: on Game Click ) ĊĠĠĠĠĠĠĠ Ġlatest Games View . setOn Game Click (:: on Game Click ) ĊĠĠĠĠĠĠĠ Ġmost R ated Games View . setOn Game Click (:: on Game Click ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġupdate Category View ( view : ĠGame Category View , Ġdata : ĠCategory Data ) Ġ{ ĊĠĠĠĠĠĠĠ Ġview . setIs Loading ( data . isLoading ) ĊĠĠĠĠĠĠĠ Ġview . set Games ( data . games ) ĊĠĠĠĠĠĠĠ Ġif Ġ(! data . isLoading Ġ&& Ġdata . games . isEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview . visibility Ġ= ĠView . GONE ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġon Game Click ( game : ĠGame ) Ġ{ ĊĠĠĠĠĠĠĠ Ġrequire Base Activity (). push Fragment ( Game Details Fragment . newInstance ( game )) ĊĠĠĠ Ġ} Ċ Ċ } Ċ