package Ġcom . am it . reward store . 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 . lifecycle . Observer Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġandroidx . navigation . Navigator Ċ import Ġandroidx . navigation . fragment . Fragment Navigator Extras Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġcom . am it . reward store . R Ċ import Ġcom . am it . reward store . databinding . Fragment Home Binding Ċ import Ġcom . am it . reward store . databinding . View holder Reward Binding Ċ import Ġcom . am it . reward store . repository . models . Reward Item Ċ import Ġcom . am it . reward store . ui . adapter . Base ViewHolder Callback Ċ import Ġcom . am it . reward store . ui . adapter . Simple Recycler Adapter Ċ import Ġcom . am it . reward store . ui . adapter . ViewHolder View Name Ċ import Ġcom . am it . reward store . ui . adapter . binder . Reward Item Binder Ċ import Ġcom . am it . reward store . ui . adapter . view ids . App ViewHolder View Name Ċ import Ġcom . am it . reward store . ui . decorator . Simple Item Decorator Ċ import Ġcom . am it . reward store . ui . view model . Rewards ViewModel Ċ import Ġdagger . h ilt . android . Android EntryPoint Ċ Ċ @ Android EntryPoint Ċ class ĠHome Fragment Ġ: ĠFragment (), ĠBase ViewHolder Callback < Reward Item , ĠView holder Reward Binding > Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbinding : ĠFragment Home Binding ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġrewards ViewModel : ĠRew ards ViewModel ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapter : ĠSimple Recycler Adapter < Reward Item > ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , ĊĠĠĠĠĠĠĠ Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding Ġ= ĠFragment Home Binding . inflate ( in flater , Ġcontainer , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġrewards ViewModel Ġ= ĠViewModel Provider ( this ). get ( Rewards ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠSimple Recycler Adapter ( Reward Item Binder ( this )) ĊĠĠĠĠĠĠĠ Ġbinding . reward List . adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠ Ġval Ġitem Gap Ġ= Ġresources . get Dimension Pixel Size ( R . dim en . dim en _ 8 ) ĊĠĠĠĠĠĠĠ Ġbinding . reward List . addItem Decoration ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSimple Item Decorator ( item Gap , Ġitem Gap , Ġitem Gap , Ġitem Gap ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġregister LiveData Observer () ĊĠĠĠĠĠĠĠ Ġreturn Ġbinding . root ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġregister LiveData Observer () Ġ{ ĊĠĠĠĠĠĠĠ Ġrewards ViewModel . rewards . observe ( view Lifecycle Owner , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter . update Data ( it ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġrewards ViewModel . load Rewards () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Item Click ( ĊĠĠĠĠĠĠĠ ĠviewHolder View Name : ĠViewHolder View Name , ĊĠĠĠĠĠĠĠ Ġdata : ĠRew ard Item , ĊĠĠĠĠĠĠĠ Ġbinding : ĠView holder Reward Binding ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( view Holder View Name ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠApp ViewHolder View Name . ITEM _ VIEW Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġgo To Reward Detail ( data , Ġbinding ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgo To Reward Detail ( reward Item : ĠRew ard Item , Ġbinding : ĠView holder Reward Binding ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnav Direction Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠHome Fragment Directions . action Home Fragment To Reward Detail Dialog ( reward Item . id ) ĊĠĠĠĠĠĠĠ Ġval Ġnavigator Extra : ĠNavigator . Extras Ġ= ĠFragment Navigator Extras ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . root Ġto Ġ" reward -${ reward Item . id }" ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfind Nav Controller (). navigate ( nav Direction , Ġnavigator Extra ) ĊĠĠĠ Ġ} Ċ }