package Ġcom . dz now . fragments Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 4 . app . Fragment Ċ import Ġandroid . support . v 7 . widget . Linear LayoutManager Ċ import Ġandroid . support . v 7 . widget . RecyclerView Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġcom . dz now . R Ċ import Ġcom . dz now . re cycl ers . Category Preview Adapter Ċ import Ġcom . dz now . models . Article Model Ċ import Ġcom . dz now . models . Category Model Ċ import Ġcom . dz now . re cycl ers . Article Preview Adapter Ċ Ċ class ĠHome Fragment Ġ: ĠFragment () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġlatest : ĠArrayList < Article Model > ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcategories : ĠArrayList < Category Model > ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcategories RecyclerView : ĠRecyclerView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġlatest RecyclerView : ĠRecyclerView ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġ@ Jvm Static ĊĠĠĠĠĠĠĠ Ġfun Ġnew Instance ( latest : ĠArrayList < Article Model >, Ġcategories : ĠArrayList < Category Model >) Ġ= ĠHome Fragment (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġarguments Ġ= ĠBundle (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġput Parcelable ArrayList (" latest ", Ġlatest ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġput Parcelable ArrayList (" categories ", Ġcategories ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġfetching Ġdata ĊĠĠĠĠĠĠĠ Ġthis . arguments ?. get Parcelable ArrayList < Article Model >(" latest ") ?. let Ġ{ Ġlatest Ġ= Ġit Ġ} ĊĠĠĠĠĠĠĠ Ġthis . arguments ?. get Parcelable ArrayList < Category Model >(" categories ") ?. let Ġ{ Ġcategories Ġ= Ġit Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġroot View Ġ= Ġinflater . inflate ( R . layout . fragment _ home , Ġcontainer , Ġfalse ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġdisplaying Ġlatest ĊĠĠĠĠĠĠĠ Ġlatest RecyclerView Ġ= Ġroot View . findViewById ( R . id . re cyclerView Latest ) Ġas ĠRecyclerView ĊĠĠĠĠĠĠĠ Ġlatest RecyclerView . layout Manager Ġ= ĠLinearLayoutManager ( activity ) ĊĠĠĠĠĠĠĠ Ġlatest RecyclerView . adapter Ġ= ĠArticle Preview Adapter ( latest ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġdisplaying Ġcategories ĊĠĠĠĠĠĠĠ Ġcategories RecyclerView Ġ= Ġroot View . findViewById ( R . id . re cyclerView Categories ) Ġas ĠRecyclerView ĊĠĠĠĠĠĠĠ Ġcategories RecyclerView . layout Manager Ġ= ĠLinearLayoutManager ( activity ) ĊĠĠĠĠĠĠĠ Ġcategories RecyclerView . adapter Ġ= ĠCategory Preview Adapter ( categories ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġroot View ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Resume () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Resume () ĊĠĠĠĠĠĠĠ Ġlatest RecyclerView . adapter Ġ= ĠArticle Preview Adapter ( latest ) ĊĠĠĠĠĠĠĠ Ġcategories RecyclerView . adapter Ġ= ĠCategory Preview Adapter ( categories ) ĊĠĠĠ Ġ} Ċ } Ċ