package Ġcom . allen . seek weather . fragment . main Ċ Ċ import Ġandroid . app . Fragment Ċ import Ġandroid . content . Context Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . design . widget . Snackbar Ċ import Ġandroid . support . v 7 . widget . Linear LayoutManager Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġcom . allen . api . He Weather . Response . He Weather All Weather Data Response Ċ import Ġcom . allen . seek weather . R Ċ import Ġcom . allen . seek weather . event . Home City ChangeEvent Ċ import Ġkotlinx . android . synt hetic . main . fragment _ main .* Ċ import Ġorg . green robot . event bus . EventBus Ċ import Ġorg . green robot . event bus . Subscribe ĊĊ Ċ class ĠMain Fragment Ġ: ĠFragment (), ĠMain Fragment Contract . View Ġ{ ĊĠĠĠ Ġprivate Ġval Ġpresenter : ĠMain Fragment Contract . Presenter Ġ= ĠMain Fragment Presenter ( this ) ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapter : ĠMain RecyclerView Adapter ĊĠĠĠ Ġoverride Ġfun Ġload RecyclerView Data ( weather Info : ĠHe Weather All Weather Data Response ) Ġ{ ĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠMain RecyclerView Adapter ( activity . application Context , Ġweather Info , Ġactivity ) ĊĠĠĠĠĠĠĠ Ġmain _ recyclerview . layout Manager Ġ= ĠLinearLayoutManager ( activity . application Context ) ĊĠĠĠĠĠĠĠ Ġmain _ recyclerview . adapter Ġ= Ġadapter ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġset Presenter ( presenter : ĠMain Fragment Contract . Presenter ) Ġ{ ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Sn ackBar ( message : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ ĠSn ackbar . make ( main _ recyclerview , Ġmessage , ĠSn ackbar . LENGTH _ SHORT ). show () ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĊĠĠĠĠĠĠĠ Ġpresenter . get Home City Weather ( arguments . getString (" City Id ")) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġinflater . inflate ( R . layout . fragment _ main , Ġcontainer , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġoverride Ġfun Ġon Attach ( context : ĠContext ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Attach ( context ) ĊĠĠĠĠĠĠĠ ĠEvent Bus . getDefault (). register ( this ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy () ĊĠĠĠĠĠĠĠ ĠEvent Bus . getDefault (). unregister ( this ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠTODO Ġcity ID Ġmay Ġnull Ġexception ĊĠĠĠ Ġ@ Subscribe ĊĠĠĠ Ġfun ĠHome City Change ( event : ĠHome City ChangeEvent ) Ġ{ ĊĠĠĠĠĠĠĠ Ġpresenter . get Home City Weather ( event . city Id !! ) ĊĠĠĠ Ġ} Ċ } Ċ