package Ġcom . rol ando as mat . aji . recipe _ details Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . activity . view Models Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . navigation . find Nav Controller Ċ import Ġandroidx . navigation . nav Args Ċ import Ġcom . rol ando as mat . aji . A ji Application Ċ import Ġcom . rol ando as mat . aji . R Ċ import Ġcom . rol ando as mat . aji . di . ViewModel Factory Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠRecipe Details Activity : ĠAppCompatActivity () Ġ{ ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar ĠviewModel Factory : ĠViewModel Factory ĊĠĠĠ Ġprivate Ġval ĠviewModel : ĠRecipe Details ViewModel Ġby Ġview Models Ġ{ ĠviewModel Factory Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġargs : ĠRecipe Details Activity Args Ġby Ġnav Args () ĊĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġ( application Context Ġas ? ĠA ji Application )?. component ()?. inject ( this ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ recipe _ details ) ĊĠĠĠĠĠĠĠ Ġintent . extras ?. let Ġ{ Ġbundle Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfind Nav Controller ( R . id . nav _ host _ fragment ). set Graph ( R . navigation . recipe _ details , Ġbundle ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġsupport ActionBar ?. hide () ĊĠĠĠĠĠĠĠ ĠviewModel . fetch Recipe Details ( args . recipe ID Arg ) ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġoverride Ġfun Ġon Support Navigate Up (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ(! find Nav Controller ( R . id . nav _ host _ fragment ). navigate Up ()){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠIf Ġnav Ġcontroller Ġdoesn 't Ġhandle ĠUp Ġnavigation , Ġmanually Ġpress Ġhardware ĠBack Ġbutton ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Back Pressed () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġtrue ĊĠĠĠ Ġ} Ċ } Ċ