package Ġinc . gray h erring . com . the david med in ash ow app . ui Ċ Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . MenuItem Ċ import Ġandroidx . core . view . Gravity Compat Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroidx . navigation . find Nav Controller Ċ import Ġandroidx . navigation . ui . Navigation UI . navigate Up Ċ import Ġandroidx . navigation . ui . Navigation UI . setup With Nav Controller Ċ import Ġandroidx . navigation . ui . on Nav Destination Selected Ċ import Ġcom . google . android . gms . oss . licenses . O ss License s Menu Activity Ċ import Ġcom . google . android . material . navigation . Navigation View . On Navigation ItemSelected Listener Ċ import Ġinc . gray h erring . com . the david med in ash ow app . R Ċ import Ġinc . gray h erring . com . the david med in ash ow app . arch . Base Activity Ċ import Ġinc . gray h erring . com . the david med in ash ow app . databinding . Activity Main Binding Ċ Ċ class ĠMainActivity Ġ: ĠBase Activity (), ĠOn Navigation ItemSelected Listener Ġ{ ĊĊĠ Ġprivate Ġval Ġnav Controller Ġby Ġlazy Ġ{ Ġfind Nav Controller ( R . id . my _ nav _ host _ fragment ) Ġ} ĊĠ Ġprivate Ġval Ġbindings Ġby Ġlazy Ġ{ ĊĠĠĠ ĠData Binding Util . set ContentView < Activity Main Binding >( ĊĠĠĠĠĠ Ġthis , ĊĠĠĠĠĠ ĠR . layout . activity _ main ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠ Ġset Support ActionBar ( bindings . toolbar ) ĊĠĠĠ Ġsetup With Nav Controller ( bindings . toolbar , Ġnav Controller , Ġbindings . drawer Layout ) ĊĠĠĠ Ġsetup With Nav Controller ( bindings . nav View , Ġnav Controller ) ĊĠĠĠ Ġbindings . nav View . set Navigation ItemSelected Listener ( this ) ĊĠĠ Ġ// Ġbindings . drawer Layout . set Drawer Lock Mode ( Drawer Layout . LOCK _ MODE _ LOCK ED _ CLOSED ) ĊĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Back Pressed () Ġ{ ĊĠĠĠ Ġif Ġ( bindings . drawer Layout . is Drawer Open ( Gravity Compat . START )) Ġ{ ĊĠĠĠĠĠ Ġbindings . drawer Layout . close Drawer ( Gravity Compat . START ) ĊĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠ Ġsuper . on Back Pressed () ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Support Navigate Up (): ĠBoolean Ġ= ĊĠĠĠ Ġnavigate Up ( nav Controller , Ġbindings . drawer Layout ) ĊĊĠ Ġoverride Ġfun Ġon Navigation ItemSelected ( item : ĠMenuItem ): ĠBoolean Ġ{ ĊĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠ Ġitem . itemId Ġ== ĠR . id . nav _ license Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ ĠstartActivity ( Intent ( this , ĠO ss License s Menu Activity :: class . java )) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġelse Ġ-> Ġitem . on Nav Destination Selected ( nav Controller ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġbindings . drawer Layout . close Drawer ( Gravity Compat . START ) ĊĠĠĠ Ġreturn Ġtrue ĊĠ Ġ} Ċ Ċ } Ċ