package Ġcom . example . mv v mex ample . play lists . 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 . recyclerview . widget . Grid LayoutManager Ċ import Ġcom . example . mv v mex ample . data . network . Resource Ċ import Ġcom . example . mv v mex ample . play lists . R Ċ import Ġcom . example . mv v mex ample . play lists . di . inject Feature Ċ import Ġcom . example . mv v mex ample . play lists . ui . adapters . Playlist Adapter Ċ import Ġcom . example . mv v mex ample . play lists . view models . Playlist ViewModel Ċ import Ġkotlinx . android . synt hetic . main . fragment _ playlist .* Ċ import Ġorg . k oin . android . view model . ext . android . viewModel Ċ Ċ class ĠPlaylist Fragment Ġ: ĠFragment () Ġ{ ĊĠĠĠ Ġprivate Ġval Ġplaylist ViewModel : ĠPlaylist ViewModel Ġby ĠviewModel () ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapter : ĠPlaylist Adapter ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġinflater . inflate ( R . layout . fragment _ playlist , Ġcontainer , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĠĠĠĠĠĠĠ Ġinject Feature () ĊĠĠĠĠĠĠĠ Ġsetup Playlist RecyclerView () ĊĠĠĠĠĠĠĠ Ġobserve Playlist () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġobserve Playlist () Ġ{ ĊĠĠĠĠĠĠĠ Ġplaylist ViewModel . user Play lists . observe ( view Lifecycle Owner , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhen Ġ( it ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠResource . Success Ġ-> Ġadapter . set Play lists ( it . data ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsetup Playlist RecyclerView () Ġ{ ĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠPlaylist Adapter ( context !! ) ĊĠĠĠĠĠĠĠ Ġplaylist RecyclerView . layout Manager Ġ= ĠGrid LayoutManager ( context , Ġ 2 ) ĊĠĠĠĠĠĠĠ Ġplaylist RecyclerView . adapter Ġ= Ġadapter ĊĠĠĠ Ġ} Ċ } Ċ