package Ġcom . nik . my car . ui . main Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . Toast Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġcom . nik . my car . adapters . Checkpoint ListAdapter Ċ import Ġcom . nik . my car . data . App Database Ċ import Ġcom . nik . my car . databinding . Fragment Checkpoint List Binding Ċ import Ġcom . nik . my car . view models . Car Details ViewModel Ċ import Ġcom . nik . my car . view models . Car Details ViewModel Factory Ċ import Ġkotlinx . android . synt hetic . main . fragment _ checkpoint _ list .* Ċ Ċ class ĠCheck point List Fragment Ġ: ĠFragment () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcar Details ViewModel : ĠCar Details ViewModel ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġfactory : ĠCar Details ViewModel Factory ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġapplication Ġ= Ġrequire NotNull ( this . activity ). application ĊĠĠĠĠĠĠĠ Ġval Ġcar Dao Ġ= ĠApp Database . getInstance ( application ). car Dao () ĊĠĠĠĠĠĠĠ Ġval Ġf ue lling Dao Ġ= ĠApp Database . getInstance ( application ). f ue lling Dao () ĊĠĠĠĠĠĠĠ Ġval Ġservice Dao Ġ= ĠApp Database . getInstance ( application ). service Dao () ĊĠĠĠĠĠĠĠ Ġval Ġcheckpoint Dao Ġ= ĠApp Database . getInstance ( application ). checkpoint Dao () ĊĠĠĠĠĠĠĠ Ġval Ġargs Ġ= ĠCar Details Fragment Args . from Bundle ( require Arguments ()) ĊĠĠĠĠĠĠĠ Ġfactory Ġ= ĠCar Details ViewModel Factory ( car Dao , Ġf ue lling Dao , Ġservice Dao Ġ, checkpoint Dao , Ġargs . car Id ) ĊĠĠĠĠĠĠĠ Ġcar Details ViewModel Ġ= ĠViewModel Provider ( this , Ġfactory ). get ( Car Details ViewModel :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= ĠFragment Checkpoint List Binding . inflate ( in flater , Ġcontainer , Ġfalse ) ĊĊĠĠĠĠĠĠĠ Ġval Ġadapter Ġ= ĠCheck point ListAdapter () ĊĠĠĠĠĠĠĠ Ġbinding . checkpoint List . adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠ Ġcar Details ViewModel . checkpoint List . observe ( view Lifecycle Owner ) Ġ{ checkpoint List Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter . submit List ( checkpoint List ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . btn Reverse Order . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcar Details ViewModel . reverse Check points () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . btn Clear Check points . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcar Details ViewModel . delete Checkpoint List () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠToast . makeText ( context , Ġ" Check points Ġcleared ", ĠToast . LENGTH _ SHORT ). show () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn Ġbinding . root ĊĠĠĠ Ġ} Ċ } Ċ