package Ġcom . die gu log . mar vel Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . fragment . app . view Models Ċ import Ġandroidx . navigation . find Nav Controller Ċ import Ġandroidx . navigation . fragment . nav Args Ċ import Ġcom . die gu log . mar vel . data . Character Response Ċ import Ġcom . die gu log . mar vel . databinding . Fragment Details Binding Ċ import Ġcom . die gu log . mar vel . utils . load G lide Ċ import Ġcom . die gu log . mar vel . utils . to Visibility Ċ import Ġcom . die gu log . mar vel . view models . Detail ViewModel Ċ import Ġdagger . h ilt . android . Android EntryPoint Ċ Ċ @ Android EntryPoint Ċ class ĠDetail Fragment Ġ: ĠFragment () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbinding : ĠFragment Details Binding ĊĠĠĠ Ġprivate Ġval Ġargs : ĠDetail Fragment Args Ġby Ġnav Args () ĊĠĠĠ Ġprivate Ġval ĠviewModel : ĠDetail ViewModel Ġby Ġview Models () ĊĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding Ġ= ĠFragment Details Binding . inflate ( in flater , Ġcontainer , Ġfalse ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġbinding . root ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĠĠĠĠĠĠĠ Ġbinding . toolbar . set Navigation Icon ( R . drawable . ic _ back ) ĊĠĠĠĠĠĠĠ Ġbinding . toolbar . set Navigation OnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . find Nav Controller (). navigate Up () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠviewModel . result . observe ( view Lifecycle Owner ){ Ġcharacter Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . progress Bar . to Visibility ( false ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif ( character != null ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsetup Data ( character ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} else { ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . description . text Ġ= ĠgetString ( R . string . network _ error ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠviewModel . get Character ById ( args . character Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsetup Data ( character : ĠCharacter Response ){ ĊĠĠĠĠĠĠĠ Ġbinding . image . load G lide ( character . thumbnail Url (" land scape _ inc red ible ")) ĊĠĠĠĠĠĠĠ Ġbinding . name . text Ġ= Ġcharacter . name ĊĠĠĠĠĠĠĠ Ġbinding . description . text Ġ= Ġif ( character . description . isEmpty ()) ĠgetString ( R . string . description ) Ġelse Ġcharacter . description ĊĠĠĠ Ġ} Ċ }