package Ġcom . ad ithy ah ar un . foot ball club . UI . Fragment Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 4 . app . Fragment Ċ import Ġandroid . support . v 4 . widget . Swipe Refresh Layout Ċ import Ġandroid . support . v 7 . widget . RecyclerView Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġcom . ad ithy ah ar un . foot ball club . Home Activity Ċ import Ġcom . ad ithy ah ar un . foot ball club . Model . Team Ċ import Ġcom . ad ithy ah ar un . foot ball club . Network Service . Data Repository Ċ import Ġcom . ad ithy ah ar un . foot ball club . R Ċ import Ġcom . ad ithy ah ar un . foot ball club . Team Activity Ċ import Ġcom . ad ithy ah ar un . foot ball club . UI . Adapter . Team Adapter Ċ import Ġcom . ad ithy ah ar un . foot ball club . UI . Presenter . Team Presenter Ċ import Ġcom . ad ithy ah ar un . foot ball club . UI . Team View Ċ import Ġorg . jetbrains . ank o . find Ċ import Ġorg . jetbrains . ank o . support . v 4 . intent For Ċ import Ġorg . jetbrains . ank o . support . v 4 . on Refresh Ċ Ċ /** Ċ Ġ* ĠA Ġfragment Ġrepresenting Ġa Ġlist Ġof ĠItems . Ċ Ġ* ĠActiv ities Ġcontaining Ġthis Ġfragment ĠMUST Ġimplement Ġthe Ċ Ġ* Ġ[ Team Fragment . On List Fragment Interaction Listener ] Ġinterface . Ċ Ġ*/ Ċ class ĠTeam Fragment Ġ: ĠFragment (), ĠTeam View Ġ{ ĊĊĠĠĠ Ġprivate Ġvar Ġteams : ĠMutable List < Team > Ġ= Ġmutable ListOf () ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġlist Team : ĠRecyclerView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġswipe Refresh : ĠSw ipe Refresh Layout ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġpresenter : ĠTeam Presenter ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapter : ĠTeam Adapter ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġval Ġparent Activity Ġ= Ġactivity Ġas ĠHome Activity ĊĠĠĠĠĠĠĠ Ġval Ġle ague Id Ġ= Ġparent Activity . league Ids [ parent Activity . selected League ] ĊĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠTeam Adapter ( context , Ġteams ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠstartActivity ( intent For < Team Activity >(" team " Ġto Ġit )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġlist Team Ġ= Ġview . find ( R . id . list ) ĊĠĠĠĠĠĠĠ Ġlist Team . adapter Ġ= Ġadapter ĊĊĠĠĠĠĠĠĠ Ġval Ġrequest Ġ= ĠData Repository . create () ĊĠĠĠĠĠĠĠ Ġpresenter Ġ= ĠTeam Presenter ( this , Ġrequest ) ĊĊĠĠĠĠĠĠĠ Ġswipe Refresh Ġ= Ġview . find ( R . id . swipe _ layout ) ĊĠĠĠĠĠĠĠ Ġswipe Refresh . on Refresh Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresenter . get Teams ( league Id ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġswipe Refresh . is Refresh ing Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġpresenter . get Teams ( league Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġview Ġ= Ġinflater . inflate ( R . layout . fragment _ teams , Ġcontainer , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġreturn Ġview ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Loading () Ġ{ ĊĠĠĠĠĠĠĠ Ġswipe Refresh . is Refresh ing Ġ= Ġtrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġhide Loading () Ġ{ ĊĠĠĠĠĠĠĠ Ġswipe Refresh . is Refresh ing Ġ= Ġfalse ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Teams ( data : ĠList < Team > ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġswipe Refresh . is Refresh ing Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġteams . clear () ĊĠĠĠĠĠĠĠ Ġdata ?. let Ġ{ Ġteams . addAll ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġadapter . notify DataSet Changed () ĊĠĠĠ Ġ} Ċ } Ċ