package Ġcom . art ur . mar ley sp oon . main . presentation . ui Ċ Ċ import Ġandroid . content . Intent Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . View . GONE Ċ import Ġandroid . view . View . VISIBLE Ċ import Ġcom . art ur . mar ley sp oon . databinding . Activity Main Binding Ċ import Ġcom . art ur . mar ley sp oon . detail . Detail Activity Ċ import Ġcom . art ur . mar ley sp oon . main . presentation . model . Recipe View Ċ import Ġcom . art ur . mar ley sp oon . main . presentation . ui . adapter . Recipe Adapter Ċ import Ġorg . k oin . android x . view model . ext . android . viewModel Ċ Ċ class ĠMainActivity Ġ: ĠAppCompatActivity (), ĠRecipe Adapter . On ItemClickListener Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbinding : ĠActivity Main Binding ĊĊĠĠĠ Ġprivate Ġval ĠviewModel : ĠMain ViewModel Ġby ĠviewModel () ĊĊĠĠĠ Ġprivate Ġval Ġrecipe Adapter Ġ= ĠRecipe Adapter ( this ) ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġbinding Ġ= ĠActivity Main Binding . inflate ( layout Inflater ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( binding . root ) ĊĊĠĠĠĠĠĠĠ Ġbinding . recipes Recycler view . adapter Ġ= Ġrecipe Adapter ĊĊĠĠĠĠĠĠĠ ĠviewModel . recipes LiveData . observe ( this , Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow Items ( it ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Item Clicked ( recipe Item : ĠRecipe View ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( this , ĠDetail Activity :: class . java ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġput Extra ( EXTRA _ RE CI PE , Ġrecipe Item ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠstartActivity ( intent ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġshow Items ( list Ġ: ĠList < Recipe View >) Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding . progress Circular . visibility Ġ= ĠG ONE ĊĠĠĠĠĠĠĠ Ġif Ġ( list . isNull OrEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . recipes Empty . visibility Ġ= ĠVIS IBLE ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . recipes Recycler view . visibility Ġ= ĠG ONE ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrecipe Adapter . submit List ( list ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . recipes Empty . visibility Ġ= ĠG ONE ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . recipes Recycler view . visibility Ġ= ĠVIS IBLE ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠEX TRA _ RE CI PE Ġ= Ġ" extra _ recipe " ĊĠĠĠ Ġ} Ċ }