package Ġcom . char le zz . pickle . fragments . folder Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġandroidx . recyclerview . widget . Grid LayoutManager Ċ import Ġcom . char le zz . pickle . Pick le Shared ViewModel Ċ import Ġcom . char le zz . pickle . databinding . Fragment Pick le Album Binding Ċ import Ġcom . char le zz . pickle . u im odel . Toolbar ViewModel Ċ import Ġcom . char le zz . pickle . util . d agger . Shared ViewModel Provider Ċ import Ġdagger . android . support . D agger Fragment Ċ import Ġjavax . inject . Inject Ċ import Ġjavax . inject . Provider Ċ Ċ class ĠPick le Album Fragment Ġ: ĠD agger Fragment () Ġ{ ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġ@ Shared ViewModel Provider ĊĠĠĠ Ġlateinit Ġvar Ġshared ViewModel Provider : ĠViewModel Provider ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġgrid LayoutManager Provider : ĠProvider < Grid LayoutManager > ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġadapter : ĠPick le Album Adapter ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar ĠviewModel Provider : ĠViewModel Provider ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġtoolbar ViewModel : ĠToolbar ViewModel ĊĊĠĠĠ Ġprivate Ġvar Ġ_ binding : ĠFragment Pick le Album Binding ? Ġ= Ġnull ĊĊĠĠĠ Ġprivate Ġval Ġbinding Ġget () Ġ= Ġ_ binding !! ĊĊĠĠĠ Ġlateinit Ġvar ĠviewModel : ĠPick le Album ViewModel ĊĊĠĠĠ Ġlateinit Ġvar Ġshared ViewModel : ĠPick le Shared ViewModel ĊĊĠĠĠ Ġlateinit Ġvar Ġgrid LayoutManager : ĠGrid LayoutManager ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġthis . viewModel Ġ= ĠviewModel Provider . get ( Pick le Album ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ Ġthis . shared ViewModel Ġ= Ġshared ViewModel Provider . get ( Pick le Shared ViewModel :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , ĊĠĠĠĠĠĠĠ Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠFragment Pick le Album Binding . inflate ( in flater , Ġcontainer , Ġfalse ). also Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ binding Ġ= Ġit ĊĠĠĠĠĠĠĠ Ġ}. root ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĠĠĠĠĠĠĠ Ġbinding . lifecycle Owner Ġ= Ġview Lifecycle Owner ĊĠĠĠĠĠĠĠ Ġ( require Activity () Ġas ĠAppCompatActivity ). set Support ActionBar ( binding . toolbar Binding . toolbar ) ĊĠĠĠĠĠĠĠ Ġbinding . toolbar ViewModel Ġ= Ġtoolbar ViewModel ĊĠĠĠĠĠĠĠ Ġbinding . re cyclerView . layout Manager Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġgrid LayoutManager Provider . get (). also Ġ{ Ġgrid LayoutManager Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġthis . grid LayoutManager Ġ= Ġgrid LayoutManager ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġbinding . re cyclerView . adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠ Ġbinding . re cyclerView . set Has Fixed Size ( true ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . items . observe ( view Lifecycle Owner ) Ġ{ Ġitems Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter . submit Items ( items ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠviewModel . item Click Event . observe ( view Lifecycle Owner ) Ġ{ Ġitem Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshared ViewModel . set Bucket Id ( item ?. album ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfind Nav Controller (). navigate Up () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy View () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy View () ĊĠĠĠĠĠĠĠ Ġ_ binding Ġ= Ġnull ĊĠĠĠ Ġ} Ċ }