/* Ċ Ġ* ĠCreated Ġby ĠLee ĠOh ĠHy ung Ġon Ġ 2 0 2 0 / 1 0 / 1 4 . Ċ Ġ*/ Ċ package Ġkr . o hy ung . m vi Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . navigation . Nav Controller Ċ import Ġandroidx . navigation . fragment . Nav Host Fragment Ċ import Ġkr . o hy ung . core . android . Base Fragment Ċ import Ġkr . o hy ung . m vi . databinding . Fragment Bottom Navigation Binding Ċ import Ġkr . o hy ung . m vi . utility . extension . set White StatusBar Ċ Ċ class ĠBottom Navigation Fragment Ġ: ĊĠĠĠ ĠBase Fragment < Fragment Bottom Navigation Binding >( R . layout . fragment _ bottom _ navigation ) Ġ{ ĊĊĠĠĠ Ġprivate Ġvar Ġchild Nav Controller : ĠNav Controller ? Ġ= Ġnull ĊĠĠĠ Ġprivate Ġvar Ġbottom Navigation Host Fragment : ĠNav Host Fragment ? Ġ= Ġnull ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate View ( in flater , Ġcontainer , ĠsavedInstanceState ) ĊĠĠĠĠĠĠĠ Ġinit Bottom Nav Host Fragment () ĊĠĠĠĠĠĠĠ Ġsetup Navigation ItemSelected Listener () ĊĠĠĠĠĠĠĠ Ġrequire Activity (). set White StatusBar () ĊĠĠĠĠĠĠĠ Ġreturn Ġbinding . root ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġinit Bottom Nav Host Fragment () Ġ{ ĊĠĠĠĠĠĠĠ Ġbottom Navigation Host Fragment Ġ= Ġchild FragmentManager . find Fragment ById ( R . id . bottom _ navigation _ host _ fragment ) Ġas ? ĠNav Host Fragment ĊĠĠĠĠĠĠĠ Ġchild Nav Controller Ġ= Ġbottom Navigation Host Fragment ?. nav Controller ĊĠĠĠĠĠĠĠ Ġchild Nav Controller ?. set Graph ( R . navigation . nav _ graph ) ĊĠĠĠĠĠĠĠ Ġchild Nav Controller ?. navigate ( R . id . fragment _ home ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsetup Navigation ItemSelected Listener () Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding . bottom Navigation View . setOn Navigation ItemSelected Listener Ġ{ Ġitem Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġdirection Ġ= Ġwhen ( item . itemId ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . menu _ home Ġ-> ĠBottom Navigation Fragment Directions . to Home Fragment () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . menu _ bookmark Ġ-> ĠBottom Navigation Fragment Directions . to Bookmark Fragment () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . menu _ settings Ġ-> ĠBottom Navigation Fragment Directions . to Settings Fragment () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġthrow ĠIllegalStateException (" invalid Ġdirection Ġof Ġbottom Ġnavigation ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġchild Nav Controller ?. navigate ( direction ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn @ setOn Navigation ItemSelected Listener Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ