package Ġcom . ton n ys un m . contacts . ui . detail Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . View Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . fragment . app . view Models Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġandroidx . navigation . fragment . nav Args Ċ import Ġandroidx . navigation . ui . AppBar Configuration Ċ import Ġandroidx . navigation . ui . setup With Nav Controller Ċ import Ġcom . ton n ys un m . contacts . R Ċ import Ġcom . ton n ys un m . contacts . databinding . Fragment Detail Binding Ċ import Ġcom . ton n ys un m . contacts . library . Android ViewModel Factory Ċ import Ġkotlinx . android . synt hetic . main . fragment _ main .* ĊĊ Ċ class ĠDetail Fragment Ġ: ĠFragment ( R . layout . fragment _ detail ) Ġ{ ĊĊĠĠĠ Ġprivate Ġval ĠviewModel Ġby Ġview Models < Detail ViewModel > Ġ{ ĊĠĠĠĠĠĠĠ ĠAndroid ViewModel Factory ( require Activity (). application ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġval Ġargs : ĠDetail Fragment Args Ġby Ġnav Args () ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġval Ġnav Controller Ġ= Ġfind Nav Controller () ĊĠĠĠĠĠĠĠ Ġval Ġapp Bar Configuration Ġ= ĠApp Bar Configuration ( nav Controller . graph ) ĊĠĠĠĠĠĠĠ Ġtoolbar . setup With Nav Controller ( nav Controller , Ġapp Bar Configuration ) ĊĊĠĠĠĠĠĠĠ Ġ// ĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= ĠFragment Detail Binding . bind ( view ) ĊĠĠĠĠĠĠĠ ĠviewModel . getUser ( args . id ). observe ( this . view Lifecycle Owner , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . user Ġ= Ġit ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} Ċ }