package Ġcom . example . cat tle log . her d _ member _ details . health _ tab ĊĊ Ċ import Ġandroid . graphics . drawable . Drawable Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . core . content . Context Compat Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . recyclerview . widget . Divider Item Decoration Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ Ċ import Ġcom . example . cat tle log . R Ċ import Ġcom . example . cat tle log . her d _ member _ details . H erd Member Details Ċ import Ġkotlinx . android . synt hetic . main . fragment _ health .* Ċ import Ġpl . pol idea . view . Zoom View ĊĊ Ċ /** Ċ Ġ* ĠA Ġsimple Ġ[ Fragment ] Ġsubclass . Ċ Ġ*/ Ċ Ċ class ĠHealth Fragment Ġ: ĠFragment () Ġ{ ĊĊĠĠĠ Ġprivate Ġvar Ġher d Member TagNumber : ĠInt Ġ= Ġ- 1 ĊĠĠĠ Ġprivate Ġvar Ġher d Member Birth Date : ĠString Ġ= Ġ"" ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġhealth ViewModel : ĠHealth ViewModel ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġhealth ViewModel Factory : ĠHealth ViewModel Factory ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġhealth RecyclerView : ĠRecyclerView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġhealth Adapter : ĠHealth ListAdapter ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġzoom View : ĠZoom View ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġher d Member TagNumber Ġ= Ġ( activity Ġas ĠH erd Member Details ). getTag Number () ĊĠĠĠĠĠĠĠ Ġher d Member Birth Date Ġ= Ġ( activity Ġas ĠH erd Member Details ). get Birth Date () ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠInf late Ġthe Ġlayout Ġfor Ġthis Ġfragment ĊĊĠĠĠĠĠĠĠ Ġval Ġv Ġ= Ġinflater . inflate ( R . layout . fragment _ health , Ġcontainer , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġzoom View Ġ= ĠZoom View ( context ) ĊĠĠĠĠĠĠĠ Ġzoom View . addView ( v ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġzoom View ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġhealth Adapter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠHealth ListAdapter ( activity !! ) ĊĠĠĠĠĠĠĠ Ġhealth RecyclerView Ġ= Ġhealth List ĊĠĠĠĠĠĠĠ Ġhealth RecyclerView . layout Manager Ġ= ĠLinearLayoutManager ( activity !! ) ĊĠĠĠĠĠĠĠ Ġhealth RecyclerView . set Has Fixed Size ( true ) ĊĠĠĠĠĠĠĠ Ġhealth RecyclerView . adapter Ġ= Ġhealth Adapter ĊĠĠĠĠĠĠĠ Ġval Ġdivider Ġ= ĠDiv ider Item Decoration ( health RecyclerView . context , ĠDiv ider Item Decoration . VERTICAL ) ĊĠĠĠĠĠĠĠ Ġdivider . set Drawable ( Context Compat . get Drawable ( activity !! , ĠR . drawable . divider ) Ġas ĠDrawable ) ĊĠĠĠĠĠĠĠ Ġhealth RecyclerView . addItem Decoration ( divider ) ĊĊĊĠĠĠĠĠĠĠ Ġ// Ġhealth ViewModel Factory Ġtakes Ġin Ġextra Ġparameters Ġ( TagNumber , ĠB irth Date ) Ġand Ġpasses Ġthem Ġto Ġhealth ViewModel ĊĠĠĠĠĠĠĠ Ġhealth ViewModel Factory Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠHealth ViewModel Factory ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactivity !!. application , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġher d Member TagNumber , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġher d Member Birth Date ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġhealth ViewModel Ġ= ĠViewModel Provider ( this , Ġhealth ViewModel Factory ). get ( Health ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ Ġhealth ViewModel . all Health . observe ( this , ĠObserver Ġ{ Ġhealth List Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhealth List ?. let Ġ{ Ġhealth Adapter . set Health List ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĊ Ċ } Ċ