package Ġcom . ali uz un . mvp movie app . top movies Ċ Ċ import Ġandroid . support . v 7 . app . AppCompatActivity Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . design . widget . Snackbar Ċ import Ġandroid . support . v 7 . widget . Default Item Animator Ċ import Ġcom . ali uz un . mvp movie app . R Ċ import Ġcom . ali uz un . mvp movie app . root . App Ċ import Ġandroid . support . v 7 . widget . Linear LayoutManager Ċ import Ġcom . ali uz un . mvp movie app . R . id .* Ċ import Ġcom . ali uz un . mvp movie app . helper . Divider Item Decoration Ċ Ċ import Ġcom . ali uz un . mvp movie app . http . apim odel . Result Ċ import Ġkotlinx . android . synt hetic . main . activity _ main .* Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠTop Movies Activity Ġ: ĠAppCompatActivity (), ĠTop Movies Activity M VP . View Ġ{ ĊĊĠĠĠ Ġval ĠTAG Ġ= ĠTop Movies Activity :: class . java . name ĊĊĠĠĠ Ġlateinit Ġvar Ġlist Adapter : ĠList Adapter ĊĠĠĠ Ġvar Ġresult List Ġ= ĠArrayList < Result >() ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġpresenter : ĠTop Movies Activity M VP . Presenter ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ main ) ĊĊĠĠĠĠĠĠĠ Ġ( application Ġas ĠApp ). component . inject ( this ) ĊĊĠĠĠĠĠĠĠ Ġlist Adapter Ġ= ĠList Adapter ( result List ) ĊĠĠĠĠĠĠĠ Ġre cyclerView . adapter Ġ= Ġlist Adapter ĊĠĠĠĠĠĠĠ Ġre cyclerView . addItem Decoration ( Divider Item Decoration ( this )) ĊĠĠĠĠĠĠĠ Ġre cyclerView . item Animator Ġ= ĠDefault Item Animator () ĊĠĠĠĠĠĠĠ Ġre cyclerView . set Has Fixed Size ( true ) ĊĠĠĠĠĠĠĠ Ġre cyclerView . layout Manager Ġ= ĠLinearLayoutManager ( this ) ĊĊĠĠĠĠĠĠĠ Ġswipe Refresh View . setOn Refresh Listener Ġ{ Ġpresenter . load Data () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Resume () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Resume () ĊĠĠĠĠĠĠĠ Ġpresenter . attach View ( this ) ĊĠĠĠĠĠĠĠ Ġpresenter . load Data () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy () ĊĠĠĠĠĠĠĠ Ġresult List . clear () ĊĠĠĠĠĠĠĠ Ġpresenter . detach View () ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġupdate Data ( results : ĠList < Result >) Ġ{ ĊĠĠĠĠĠĠĠ Ġlist Adapter . update DataList ( results ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Sn ackBar ( msg : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ ĠSn ackbar . make ( root View , Ġmsg , ĠSn ackbar . LENGTH _ SHORT ). show () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġset Loading ( isLoading : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġswipe Refresh View . is Refresh ing Ġ= ĠisLoading ĊĠĠĠ Ġ} Ċ Ċ } Ċ