/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 1 7 ĠFull ĠMe ad ĠAl che mist , ĠLLC . Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġcom . full me ad al che mist . must watch . ui . recipe Ċ Ċ import Ġandroid . arch . lifecycle . Observer Ċ 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 Ġandroidx . navigation . find Nav Controller Ċ import Ġcom . full me ad al che mist . must watch . R Ċ import Ġcom . full me ad al che mist . must watch . ui . common . Main ViewModel Ċ import Ġcom . full me ad al che mist . must watch . vo . Recipe Ċ import Ġcom . full me ad al che mist . must watch . vo . User Ċ import Ġorg . k oin . android . view model . ext . android . shared ViewModel Ċ import Ġtim ber . log . Tim ber Ċ Ċ class ĠRecipe List Fragment Ġ: ĠFragment () Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġre cyclerView : ĠRecyclerView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapter : ĠRecipe ListView Adapter ĊĊĠĠĠ Ġval ĠviewModel : ĠMain ViewModel Ġby Ġshared ViewModel () ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġroot View Ġ= Ġinflater . inflate ( R . layout . recipe _ list , Ġcontainer , Ġfalse ) ĊĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠRecipe ListView Adapter ( null , Ġobject Ġ: ĠRecipe ListView Adapter . Recipe Click Callback Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun ĠonClick ( recipe : ĠRecipe ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTim ber . e (" Navig ating Ġto Ġthe Ġdetail Ġview Ġfor ĠRecipe Ġ# ${ recipe . id }") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbundle Ġ= ĠBundle () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbundle . put Long ( Recipe . RE CI PE _ ID , Ġrecipe . id ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġroot View . find Nav Controller (). navigate ( R . id . recipe Detail Fragment , Ġbundle ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ ĠviewModel . getCurrent User (). observe ( this , ĠObserver < User > Ġ{ Ġuser Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuser ?. uid ?. let Ġ{ ĠuserId Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . get Recipes ( userId ). observe ( this , ĠObserver < List < Recipe >> Ġ{ Ġrecipes Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġadapter . data Set Ġ= Ġrecipes ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġadapter . notify DataSet Changed () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġre cyclerView Ġ= Ġroot View . findViewById ( R . id . recipe _ list ) ĊĠĠĠĠĠĠĠ Ġval Ġll m Ġ= ĠLinearLayoutManager ( context ) ĊĠĠĠĠĠĠĠ Ġll m . orientation Ġ= ĠLinearLayoutManager . VERTICAL ĊĠĠĠĠĠĠĠ Ġre cyclerView . set Has Fixed Size ( true ) ĊĠĠĠĠĠĠĠ Ġre cyclerView . layout Manager Ġ= Ġll m ĊĠĠĠĠĠĠĠ Ġre cyclerView . adapter Ġ= Ġadapter ĊĊĠĠĠĠĠĠĠ Ġreturn Ġroot View ĊĠĠĠ Ġ} Ċ }