package Ġcom . app . ly ng ua . views . Categories Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġcom . app . ly ng ua . R Ċ import Ġcom . app . ly ng ua . controllers . Category Controller Ċ import Ġkotlinx . android . synt hetic . main . fragment _ practice . view .* Ċ Ċ class ĠPract ice Ġ: ĠFragment () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcategory Controller : ĠCategory Controller ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView ? Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ// ĠInf late Ġthe Ġlayout Ġfor Ġthis Ġfragment ĊĠĠĠĠĠĠĠ Ġval Ġview Ġ= Ġinflater . inflate ( R . layout . fragment _ practice , Ġcontainer , Ġfalse ) ĊĊĠĠĠĠĠĠĠ Ġcategory Controller Ġ= ĠCategory Controller ( require Context ()) ĊĊĠĠĠĠĠĠĠ Ġ// ĠCall Ġthe Ġcategory Ġlist Ġadapter Ġto Ġinf late Ġall Ġthe Ġdata Ġinside Ġthe Ġre cycler Ġview ĊĠĠĠĠĠĠĠ Ġval Ġlist Adapter Ġ= ĠCategory ListAdapter () ĊĠĠĠĠĠĠĠ Ġval Ġcategory RecyclerView Ġ= Ġview . category RecyclerView ĊĠĠĠĠĠĠĠ Ġcategory RecyclerView . adapter Ġ= Ġlist Adapter ĊĊĠĠĠĠĠĠĠ Ġcategory RecyclerView . layout Manager Ġ= ĠLinearLayoutManager ( require Context ()) ĊĊĠĠĠĠĠĠĠ Ġcategory Controller . read All Data . observe ( view Lifecycle Owner , ĠObserver Ġ{ Ġcategory Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlist Adapter . setData ( category ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġview . add Category Button . setOnClickListener { ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfind Nav Controller (). navigate ( R . id . action _ practice _ to _ add Category ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn Ġview ĊĠĠĠ Ġ} ĊĊĊ Ċ }