package Ġcom . example . library . navigation Ċ Ċ import Ġandroidx . appcompat . widget . Toolbar Ċ import Ġandroidx . databinding . ViewData Binding Ċ import Ġandroidx . navigation . Activity Navigator Ċ import Ġandroidx . navigation . fragment . Nav Host Fragment Ċ import Ġandroidx . navigation . ui . AppBar Configuration Ċ import Ġandroidx . navigation . ui . navigate Up Ċ import Ġandroidx . navigation . ui . setup ActionBar With Nav Controller Ċ import Ġcom . example . library . binding . Binding Activity Ċ Ċ open Ġclass ĠNavigation Activity < VB : ĠView Data Binding >( private Ġval Ġlayout Id : ĠInt , Ġprivate Ġval Ġnav Host Id : ĠInt ) Ġ: ĠBinding Activity < VB >( layout Id ){ ĊĠĠĠ Ġprivate Ġval Ġnav Controller Ġby Ġlazy Ġ{ Ġ( support FragmentManager . find Fragment ById ( nav Host Id ) Ġas ĠNav Host Fragment ). nav Controller } ĊĠĠĠ Ġprivate Ġval Ġapp Bar Configuration Ġby Ġlazy Ġ{ ĠApp Bar Configuration ( nav Controller . graph )} ĊĊĠĠĠ Ġoverride Ġfun Ġset Support ActionBar ( toolbar : ĠToolbar ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . set Support ActionBar ( toolbar ) ĊĠĠĠĠĠĠĠ Ġsetup ActionBar With Nav Controller ( nav Controller , Ġapp Bar Configuration ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Support Navigate Up (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġsuper . on Support Navigate Up () Ġ|| Ġnav Controller . navigate Up ( app Bar Configuration ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġfinish () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . finish () ĊĠĠĠĠĠĠĠ ĠActivity Navigator . apply Pop Animations To Pending Transition ( this ) ĊĠĠĠ Ġ} Ċ Ċ }