package Ġcom . example . fi ro z has an . ret rofit kotlin example . view . fragments Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . util . Log Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . lifecycle . ViewModel Providers Ċ import Ġcom . example . fi ro z has an . ret rofit kotlin example . R Ċ import Ġcom . example . fi ro z has an . ret rofit kotlin example . databinding . Country Detail Frag Binding Ċ import Ġcom . example . fi ro z has an . ret rofit kotlin example . util . Cor outines Ċ import Ġcom . example . fi ro z has an . ret rofit kotlin example . viewModel . Country Details ViewModel Ċ import Ġcom . example . fi ro z has an . ret rofit kotlin example . viewModel . Country Details ViewModel Factory Ċ import Ġorg . kode in . di . K ode in Aware Ċ import Ġorg . kode in . di . android . x . kode in Ċ import Ġorg . kode in . di . generic . instance ĊĊ Ċ class ĠCount ries Details Frag : ĠFragment (), ĠK ode in Aware Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠCountry Details ViewModel ĊĠĠĠ Ġoverride Ġval Ġk ode in Ġby Ġk ode in () ĊĠĠĠ Ġprivate Ġval Ġfactory : ĠCountry Details ViewModel Factory Ġby Ġinstance () ĊĠĠĠ Ġvar Ġalpha Value Ġ= Ġ" empty " ĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠĠ Ġ// alpha Value Ġ= Ġarguments !!. getString (" alpha ") ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbundle Ġ= Ġthis . arguments ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmy Value Ġ= Ġbundle !!. getString (" message ") ĊĠĠĠĠĠĠĠ ĠLog . d (" al hab ib i ", Ġ" ya alpha Ġ= Ġ$ my Value ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġalpha Value Ġ= Ġmy Value ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLog . d (" frag lifecycle ", Ġ" on create view ") ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠViewModel Providers . of ( this , Ġfactory ). get ( Country Details ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= ĠData Binding Util . inflate < Country Detail Frag Binding >( in flater , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR . layout . country _ detail _ frag , Ġcontainer , Ġfalse ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . lifecycle Owner Ġ= Ġactivity ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . view model Ġ= ĠviewModel ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbind UI () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ// Toast . makeText ( activity ," s fs df sf ", Toast . LENGTH _ LONG ). show () ĊĠĠĠĠĠĠĠ Ġreturn Ġbinding . root ĊĠĠĠĠĠĠ Ġ// Ġreturn Ġinflater . inflate ( R . layout . fragment _ search _ frag , Ġcontainer , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Activity Created ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Activity Created ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġ// viewModel Ġ= ĠViewModel Providers . of ( this , Ġfactory ). get ( Country Details ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ ĠLog . d (" frag lifecycle ", Ġ" on Activity Created ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Attach ( context : ĠContext ) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Attach ( context ) ĊĠĠĠĠĠĠĠ ĠLog . d (" frag lifecycle ", Ġ" on Attach ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠLog . d (" frag lifecycle ", Ġ" onCreate ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonStart () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onStart () ĊĠĠĠĠĠĠĠ ĠLog . d (" frag lifecycle ", Ġ" onStart ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Resume () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Resume () ĊĠĠĠĠĠĠĠ ĠLog . d (" frag lifecycle ", Ġ" on Resume ") ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġprivate Ġfun Ġbind UI () Ġ= ĠCor outines . main Ġ{ ĊĠĠĠĠĠĠĠ Ġ// progress Bar . show () ĊĠĠĠĠĠĠĠ ĠviewModel . alpha 2 Country Details ( alpha Value ) ĊĠĠĠ Ġ} Ċ }