package Ġio . bar an m ich al . the case again st li ved ata . movies . view Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . design . widget . Snackbar Ċ import Ġandroid . support . v 4 . content . Context Compat Ċ import Ġandroid . support . v 7 . app . AppCompatActivity Ċ import Ġandroid . support . v 7 . widget . Divider Item Decoration Ċ import Ġandroid . view . View Ċ import Ġio . bar an m ich al . the case again st li ved ata . Life Application Ċ import Ġio . bar an m ich al . the case again st li ved ata . R Ċ import Ġio . bar an m ich al . the case again st li ved ata . base . presenter . Presenter Providers Ċ import Ġio . bar an m ich al . the case again st li ved ata . movies . data . Movie Ċ import Ġio . bar an m ich al . the case again st li ved ata . movies . di . Movies Module Ċ import Ġio . bar an m ich al . the case again st li ved ata . movies . presenter . Movies Presenter Ċ import Ġio . bar an m ich al . the case again st li ved ata . movies . presenter . Movies Presenter Factory Ċ import Ġkotlinx . android . synt hetic . main . activity _ movies .* Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠMov ies Activity Ġ: ĠAppCompatActivity (), ĠMov ies View Ġ{ ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġmovies Presenter Factory : ĠMov ies Presenter Factory ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġpresenter : ĠMov ies Presenter ĊĊĠĠĠ Ġprivate Ġval Ġadapter Ġ= ĠMov ies Adapter () ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ movies ) ĊĊĠĠĠĠĠĠĠ Ġinject Dependencies () ĊĊĠĠĠĠĠĠĠ Ġsetup Swipe Refresh () ĊĠĠĠĠĠĠĠ Ġsetup RecyclerView () ĊĊĠĠĠĠĠĠĠ Ġpresenter Ġ= ĠPres enter Providers . of ( this , Ġmovies Presenter Factory ). get ( Movies Presenter :: class . java ) ĊĠĠĠĠĠĠĠ Ġpresenter . attach View ( this , Ġlifecycle ) ĊĠĠĠĠĠĠĠ Ġpresenter . load Movies () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġinject Dependencies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġapp Ġ= Ġapplication Ġas ĠLife Application ĊĠĠĠĠĠĠĠ Ġapp . getComponent () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. plus ( Movies Module ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. inject ( this ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsetup Swipe Refresh () Ġ{ ĊĠĠĠĠĠĠĠ Ġsw iper ef resh _ movies . setColor Scheme Colors ( Context Compat . getColor ( this , ĠR . color . color Accent )) ĊĠĠĠĠĠĠĠ Ġsw iper ef resh _ movies . setOn Refresh Listener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresenter . refresh Movies () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsetup RecyclerView () Ġ{ ĊĠĠĠĠĠĠĠ Ġre cycler view _ movies . addItem Decoration ( Divider Item Decoration ( this , ĠDiv ider Item Decoration . VERTICAL )) ĊĠĠĠĠĠĠĠ Ġre cycler view _ movies . adapter Ġ= Ġadapter ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Loading () Ġ{ ĊĠĠĠĠĠĠĠ Ġsw iper ef resh _ movies . visibility Ġ= ĠView . GONE ĊĠĠĠĠĠĠĠ Ġtext view _ movies _ error . visibility Ġ= ĠView . GONE ĊĊĠĠĠĠĠĠĠ Ġprogress bar _ movies . visibility Ġ= ĠView . VISIBLE ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Refresh () Ġ{ ĊĠĠĠĠĠĠĠ Ġsw iper ef resh _ movies . is Refresh ing Ġ= Ġtrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Movies ( movies : ĠList < Movie >) Ġ{ ĊĠĠĠĠĠĠĠ Ġprogress bar _ movies . visibility Ġ= ĠView . GONE ĊĠĠĠĠĠĠĠ Ġtext view _ movies _ error . visibility Ġ= ĠView . GONE ĊĊĠĠĠĠĠĠĠ Ġsw iper ef resh _ movies . visibility Ġ= ĠView . VISIBLE ĊĠĠĠĠĠĠĠ Ġsw iper ef resh _ movies . is Refresh ing Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġadapter . update Movies ( movies ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Loading Error ( message : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġprogress bar _ movies . visibility Ġ= ĠView . GONE ĊĠĠĠĠĠĠĠ Ġsw iper ef resh _ movies . visibility Ġ= ĠView . GONE ĊĊĠĠĠĠĠĠĠ Ġtext view _ movies _ error . visibility Ġ= ĠView . VISIBLE ĊĠĠĠĠĠĠĠ Ġtext view _ movies _ error . text Ġ= Ġmessage ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Refresh Error ( message : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġsw iper ef resh _ movies . is Refresh ing Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ ĠSn ackbar . make ( layout _ movies , Ġmessage , ĠSn ackbar . LENGTH _ SHORT ). run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Action ( R . string . retry ) Ġ{ Ġpresenter . retry Refresh Clicked () Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ