package Ġcom . v ydra . poss um us dr inks . dr inks . favorites Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . lifecycle . ViewModel Providers Ċ import Ġandroidx . recyclerview . widget . Grid LayoutManager Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . v ydra . poss um us dr inks . R Ċ import Ġcom . v ydra . poss um us dr inks . databinding . Fragment F avorites Binding Ċ Ċ class ĠF avorites Fragment Ġ: ĠFragment () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbinding : ĠFragment F avorites Binding ĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠF avorites ViewModel ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= ĠData Binding Util . inflate < Fragment F avorites Binding >( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinflater , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . layout . fragment _ favorites , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontainer , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠVIEW MODEL ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠViewModel Providers . of ( this ). get ( F avorites ViewModel :: class . java ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . dr inks . observe ( view Lifecycle Owner , ĠObserver { ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . re cyclerView . adapter Ġ= ĠF avorites Adapter ( it ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġval Ġlayout Manager : ĠRecyclerView . LayoutManager Ġ= ĠLinearLayoutManager ( activity ) ĊĠĠĠĠĠĠĠ Ġbinding . re cyclerView . layout Manager Ġ= ĠGrid LayoutManager ( this . context , Ġ 2 ) ĊĠĠĠĠĠĠĠ Ġbinding . re cyclerView . set Has Fixed Size ( true ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġbinding . root ĊĠĠĠ Ġ} Ċ }