package Ġcom . example . sharing ang . ui . fragments Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . fragment . app . activity ViewModels Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġandroidx . recyclerview . widget . Grid LayoutManager Ċ import Ġcom . example . sharing ang . auth . CurrentUser Provider Ċ import Ġcom . example . sharing ang . databinding . Fragment Wish list View Binding Ċ import Ġcom . example . sharing ang . models . Item Ċ import Ġcom . example . sharing ang . ui . adapters . Item Listener Ċ import Ġcom . example . sharing ang . ui . adapters . Items Adapter Ċ import Ġcom . example . sharing ang . view models . Items ViewModel Ċ import Ġcom . example . sharing ang . view models . UserProfile ViewModel Ċ import Ġdagger . h ilt . android . Android EntryPoint Ċ import Ġjavax . inject . Inject Ċ Ċ @ Android EntryPoint Ċ class ĠW ish list View Fragment Ġ: ĠFragment () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbinding : ĠFragment Wish list View Binding ĊĠĠĠ Ġprivate Ġval ĠviewModel : ĠItems ViewModel Ġby Ġactivity ViewModels () ĊĠĠĠ Ġprivate Ġval Ġuser ViewModel : ĠUser Profile ViewModel Ġby Ġactivity ViewModels () ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar ĠcurrentUser Provider : ĠCurrent User Provider ĊĊĠĠĠ Ġoverride Ġfun Ġon Resume () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Resume () ĊĠĠĠĠĠĠĠ Ġcheck User () ĊĠĠĠĠĠĠĠ Ġuser ViewModel . refresh List UI ( viewModel ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding Ġ= ĠFragment Wish list View Binding . inflate ( in flater , Ġcontainer , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġval Ġadapter Ġ= Ġsetup Item Adapter () ĊĠĠĠĠĠĠĠ Ġbinding . wishlist view . adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠ Ġbinding . wishlist view . layout Manager Ġ= ĠGrid LayoutManager ( context , Ġ 2 ) ĊĠĠĠĠĠĠĠ ĠviewModel . add Observer ( view Lifecycle Owner , Ġadapter , ĠItems ViewModel . OB SERV ABLE S . W ISH LIST ) ĊĠĠĠĠĠĠĠ Ġuser ViewModel . refresh List UI ( viewModel ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . setup Item Navigation ( view Lifecycle Owner , Ġthis . find Nav Controller (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ{ Ġitem Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠW ish list View Fragment Directions . action Wish list View Fragment To Detailed Item Fragment ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġitem ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġcheck User () ĊĠĠĠĠĠĠĠ Ġreturn Ġbinding . root ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcheck User () Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding . is Authenticated Ġ= ĠcurrentUser Provider . getCurrent UserId () Ġ!= Ġnull ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠ Ġ* ĠSetup Ġthe Ġitem Ġadapter Ġfor Ġa Ġre cycler Ġview . ĊĠĠĠ Ġ*/ ĊĠĠĠ Ġprivate Ġfun Ġsetup Item Adapter (): ĠItems Adapter Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġon View Ġ= Ġ{ Ġitem : ĠItem Ġ-> ĠviewModel . on View Item ( item ) Ġ} ĊĠĠĠĠĠĠĠ Ġreturn ĠItems Adapter ( Item Listener ( on View ), Ġrequire Context ()) ĊĠĠĠ Ġ} Ċ } Ċ