package Ġcom . example . android . navigation Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . Motion Event Ċ import Ġandroid . view . input method . Input Method Manager Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroidx . drawer layout . widget . Drawer Layout Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġandroidx . navigation . find Nav Controller Ċ import Ġandroidx . navigation . ui . AppBar Configuration Ċ import Ġandroidx . navigation . ui . Navigation UI Ċ import Ġcom . example . android . navigation . databinding . Activity Main Binding Ċ import Ġtim ber . log . Tim ber ĊĊ Ċ late init Ġvar Ġmaster ViewModel : ĠMaster ViewModel ĊĊ Ċ class ĠMainActivity Ġ: ĠAppCompatActivity () Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġapp Bar Configuration : ĠApp Bar Configuration ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdrawer Layout : ĠDraw er Layout ĊĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġ@ Suppress (" UNUSED _ VARIABLE ") ĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= ĠData Binding Util . set ContentView < Activity Main Binding >( this , ĠR . layout . activity _ main ) ĊĠĠĠĠĠĠĠ Ġdrawer Layout Ġ= Ġbinding . drawer Layout ĊĠĠĠĠĠĠĠ Ġval Ġnav Controller Ġ= Ġthis . find Nav Controller ( R . id . my Nav Host Fragment ) ĊĠĠĠĠĠĠĠ ĠNavigation UI . setup ActionBar With Nav Controller ( this , Ġfind Nav Controller ( R . id . my Nav Host Fragment ), Ġdrawer Layout ) ĊĠĠĠĠĠĠĠ ĠNavigation UI . setup With Nav Controller ( binding . nav View , Ġfind Nav Controller ( R . id . my Nav Host Fragment )) ĊĠĠĠĠĠĠĠ Ġapp Bar Configuration Ġ= ĠApp Bar Configuration ( nav Controller . graph , Ġdrawer Layout ) ĊĠĠĠĠĠĠĠ Ġmaster ViewModel Ġ= ĠViewModel Provider ( this ). get (( Master ViewModel :: class . java )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Support Navigate Up (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnav Controller Ġ= Ġfind Nav Controller ( R . id . my Nav Host Fragment ) ĊĠĠĠĠĠĠĠ Ġreturn ĠNavigation UI . navigate Up ( nav Controller , Ġdrawer Layout ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// this Ġfunction Ġhide s Ġsoft - keyboard Ġwhen Ġclicked Ġon Ġscreen ĊĠĠĠ Ġoverride Ġfun Ġdispatch Touch Event ( ev : ĠMotion Event ?): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( current Focus Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġimm Ġ= Ġget System Service ( Context . INPUT _ METHOD _ SERVICE ) Ġas ĠInput Method Manager ĊĠĠĠĠĠĠĠĠĠĠĠ Ġimm . hide Soft Input From Window ( current Focus !!. window Token , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġsuper . dispatch Touch Event ( ev ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Resume () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Resume () ĊĠĠĠĠĠĠĠ ĠTim ber . i (" on Resume ĠCalled ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Restart () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Restart () ĊĠĠĠĠĠĠĠ ĠTim ber . i (" on Restart ĠCalled ") ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Pause () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Pause () ĊĠĠĠĠĠĠĠ ĠTim ber . i ((" on Ġp au ze Ġcalled ")) ĊĠĠĠ Ġ} Ċ } ĊĊ