package Ġes . fr on 9 9 . Food organ ize . Fragments . Activity Total Ċ Ċ 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 . recyclerview . widget . Linear LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . google . android . material . floating action button . Floating ActionButton Ċ import Ġes . fr on 9 9 . Food organ ize . Adapters . Adapter List Menus Ċ import Ġes . fr on 9 9 . Food organ ize . Dao . Model . Food Dao Ċ import Ġes . fr on 9 9 . Food organ ize . Dao . Model . Menu With Food s Ċ import Ġes . fr on 9 9 . Food organ ize . R Ċ import Ġes . fr on 9 9 . Food organ ize . ViewModels . Activity Total VM ĊĊ Ċ class ĠFragment List Menus Ġ: ĠFragment () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġactivity Total VM Ġ: ĠActivity Total VM ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġre cyclerView Menus Ġ: ĠRecyclerView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapter RecyclerView Menus Ġ: ĠAdapter List Menus ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġlist Menus : ĠArrayList < Menu With Food s > ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġinflater . inflate ( R . layout . fragment _ list _ menus , Ġcontainer , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġactivity Total VM Ġ= ĠViewModel Provider ( require Activity ()). get ( Activity Total VM :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġlist Menus Ġ= Ġif Ġ( activity Total VM . menus . value Ġ!= Ġnull ){ ArrayList ( activity Total VM . menus . value )} else { ArrayList ()} ĊĊĠĠĠĠĠĠĠ Ġin iz ial ite Views ( view ) ĊĊĠĠĠĠĠĠĠ Ġset OnClick s ( view ) ĊĊĠĠĠĠĠĠĠ Ġset Observer s () ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġin iz ial ite Views ( view Ġ: ĠView ){ ĊĊĠĠĠĠĠĠĠ Ġ/ ************************************************ **** R . id . recycler List Menus ************************************************ ****/ ĊĊĠĠĠĠĠĠĠ Ġre cyclerView Menus Ġ= Ġview . findViewById ( R . id . recycler List Menus ) ĊĠĠĠĠĠĠĠ Ġre cyclerView Menus . layout Manager Ġ= ĠLinearLayoutManager ( context ) ĊĠĠĠĠĠĠĠ Ġadapter RecyclerView Menus Ġ= ĠAdapter List Menus ( require Activity (), list Menus ) ĊĠĠĠĠĠĠĠ Ġre cyclerView Menus . adapter Ġ= Ġadapter RecyclerView Menus ĊĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġset OnClick s ( view Ġ: ĠView ){ ĊĊĠĠĠĠĠĠĠ Ġ/ ************************************************ **** R . id . float Action Btn ************************************************ ****/ ĊĊĠĠĠĠĠĠĠ Ġview . findViewById < Floating ActionButton >( R . id . float Action Btn ). setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactivity Total VM . menus Selected Ġ= ĠMenu With Food s () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactivity Total VM . change Activity Selected (" Fragment Create Menu ") ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġset Observer s (){ ĊĊĠĠĠĠĠĠĠ Ġ/ ************************************************ **** activity Total VM . menus ************************************************ ****/ ĊĊĠĠĠĠĠĠĠ Ġactivity Total VM . menus . observe ( require Activity (), Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter RecyclerView Menus . change Data ( ArrayList ( it )) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠ Ġ} Ċ Ċ }