package Ġcom . example . android . track mys leep quality . sleep detail Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġcom . example . android . track mys leep quality . database . Sleep Database Ċ import Ġcom . example . android . track mys leep quality . database . Sleep Night Ċ import Ġcom . example . android . track mys leep quality . databinding . Fragment Sleep Detail Binding Ċ Ċ class ĠSleep Detail Fragment : ĠFragment (), ĠSleep Detail Scene Ġ{ ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= ĠFragment Sleep Detail Binding . inflate ( in flater , Ġcontainer , Ġfalse ) ĊĊĠĠĠĠĠĠĠ Ġval Ġapplication Ġ= Ġrequire NotNull ( this . activity ). application ĊĠĠĠĠĠĠĠ Ġval Ġdatabase Ġ= ĠSleep Database . getInstance ( application ). sleep Database Dao ĊĠĠĠĠĠĠĠ Ġval Ġnight Id Ġ= ĠSleep Detail Fragment Args . from Bundle ( arguments !! ). night Key ĊĠĠĠĠĠĠĠ Ġval Ġfactory Ġ= ĠSleep Detail ViewModel Factory ( night Id , Ġdatabase ) ĊĠĠĠĠĠĠĠ Ġval ĠviewModel Ġ= ĠViewModel Provider ( this , Ġfactory ). get ( Sleep Detail ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ ĠviewModel . scene Ġ= Ġthis ĊĊĠĠĠĠĠĠĠ Ġbinding . lifecycle Owner Ġ= Ġthis ĊĠĠĠĠĠĠĠ Ġbinding . sleep Detail ViewModel Ġ= ĠviewModel ĊĠĠĠĠĠĠĠ Ġreturn Ġbinding . root ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonClose () Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity ?. on Back Pressed () ĊĠĠĠ Ġ} Ċ }