package Ġde . kt bl . e ik ot iger . view . fragment . recording . setup čĊč Ċ import Ġandroid . os . Bundle č Ċ import Ġandroid . view . LayoutInflater č Ċ import Ġandroid . view . View č Ċ import Ġandroid . view . ViewGroup č Ċ import Ġandroidx . appcompat . widget . Toolbar č Ċ import Ġandroidx . fragment . app . Dialog Fragment č Ċ import Ġandroidx . fragment . app . activity ViewModels č Ċ import Ġandroidx . fragment . app . view Models č Ċ import Ġandroidx . lifecycle . ViewModel Provider č Ċ import Ġandroidx . navigation . Navigation č Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager č Ċ import Ġde . kt bl . android . shared library . view . activity . Bar H ider č Ċ import Ġde . kt bl . e ik ot iger . databinding . Dialog Choose Branch Binding č Ċ import Ġde . kt bl . e ik ot iger . di . Injectable č Ċ import Ġde . kt bl . e ik ot iger . view . adapter . recording . Simple Animal Category Branch Adapter č Ċ import Ġde . kt bl . e ik ot iger . view . getDefault List Space Item č Ċ import Ġde . kt bl . e ik ot iger . view . view model . production direction . Simple Animal Category Branch ListItem č Ċ import Ġde . kt bl . e ik ot iger . view . view model . recording . manager . Recording Environment č Ċ import Ġde . kt bl . e ik ot iger . view . view model . recording . setup . Choose Animal Branch Dialog VM č Ċ import Ġtim ber . log . Tim ber č Ċ import Ġjavax . inject . Inject čĊč Ċ class ĠChoose Animal Category Branch Dialog Ġ: ĠDialog Fragment (), ĠInjectable Ġ{ čĊĠĠĠ Ġcompanion Ġobject Ġ{ čĊĠĠĠĠĠĠĠ Ġval ĠTAG Ġ= ĠChoose Animal Category Branch Dialog :: class . java . simple Name čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Inject čĊĠĠĠ Ġlateinit Ġvar ĠviewModel Factory : ĠViewModel Provider . Factory čĊčĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtoolbar : ĠToolbar čĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġroot : ĠView čĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbinding : ĠDialog Choose Branch Binding čĊĠĠĠ Ġprivate Ġval Ġrecording Environment : ĠRecord ing Environment Ġby Ġactivity ViewModels ( this :: viewModel Factory ) čĊĠĠĠ Ġprivate Ġval Ġchoose Animal Branch Dialog VM : ĠChoose Animal Branch Dialog VM Ġby Ġview Models Ġ{ Ġthis . viewModel Factory Ġ} čĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbranch ListAdapter : ĠSimple Animal Category Branch Adapter čĊčĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView Ġ{ čĊĠĠĠĠĠĠĠ Ġthis . binding Ġ= ĠDialog Choose Branch Binding . inflate ( in flater ) čĊĠĠĠĠĠĠĠ Ġthis . root Ġ= Ġbinding . root čĊĠĠĠĠĠĠĠ Ġthis . toolbar Ġ= Ġbinding . choose Branch Toolbar čĊĠĠĠĠĠĠĠ Ġval Ġbar H ider Ġ= Ġthis . activity Ġas ĠBar H ider čĊĠĠĠĠĠĠĠ Ġbar H ider . hide Bar () čĊĠĠĠĠĠĠĠ Ġreturn Ġthis . root čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ čĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) čĊĠĠĠĠĠĠĠ Ġtoolbar . set Navigation OnClickListener Ġ{ ĠNavigation . find Nav Controller ( view ). pop Back Stack () Ġ} čĊĠĠĠĠĠĠĠ Ġbinding . lifecycle Owner Ġ= Ġview Lifecycle Owner čĊĠĠĠĠĠĠĠ Ġsetup RecyclerView () čĊĠĠĠĠĠĠĠ Ġthis . branch ListAdapter Ġ= ĠSimple Animal Category Branch Adapter ( view Lifecycle Owner ) čĊĠĠĠĠĠĠĠ Ġbinding . branch RecyclerView . adapter Ġ= Ġbranch ListAdapter čĊĠĠĠĠĠĠĠ Ġthis . choose Animal Branch Dialog VM . branch Items . observe ( this , Ġthis :: on Branch List Update ) čĊĠĠĠĠĠĠĠ Ġthis . recording Environment . animal Category Instance ID . observe ( this ) Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠ Ġchoose Animal Branch Dialog VM . instance ID . value Ġ= Ġit čĊĠĠĠĠĠĠĠ Ġ} čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġprivate Ġfun Ġon Branch List Update ( items : ĠList < Simple Animal Category Branch ListItem >) Ġ{ čĊĠĠĠĠĠĠĠ Ġ// ĠFirst , Ġjust Ġto Ġbe Ġsure , Ġremove Ġcallback - listener Ġof Ġold Ġlist - items , čĊĠĠĠĠĠĠĠ Ġ// Ġevent Ġthough Ġthese Ġelements Ġshould Ġnever Ġbe Ġclicked . čĊĠĠĠĠĠĠĠ Ġfor Ġ( element Ġin Ġbranch ListAdapter . dataset ) Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠ Ġelement . callback Ġ= Ġnull čĊĠĠĠĠĠĠĠ Ġ} čĊčĊĠĠĠĠĠĠĠ Ġfor Ġ( element Ġin Ġitems ) Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠ Ġelement . callback Ġ= Ġthis :: on Branch ListItem Selected čĊĠĠĠĠĠĠĠ Ġ} čĊĠĠĠĠĠĠĠ Ġbranch ListAdapter . dataset Ġ= Ġitems čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġprivate Ġfun Ġon Branch ListItem Selected ( item : ĠSimple Animal Category Branch ListItem ) Ġ{ čĊĠĠĠĠĠĠĠ Ġrecording Environment . current Stock Id . value Ġ= Ġitem . stock ID čĊĠĠĠĠĠĠĠ ĠNavigation . find Nav Controller ( root ). pop Back Stack () čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġprivate Ġfun Ġsetup RecyclerView () Ġ{ čĊĠĠĠĠĠĠĠ Ġval Ġlayout Manager Ġ= Ġbinding . branch RecyclerView . layout Manager Ġas ĠLinearLayoutManager ? čĊĠĠĠĠĠĠĠ Ġif Ġ( layout Manager Ġ!= Ġnull ) Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġdivider Decoration Ġ= ĠgetDefault List Space Item ( this . require Context ()) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . branch RecyclerView . addItem Decoration ( divider Decoration ) čĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠ ĠTim ber . tag ( TAG ). w (" Some how Ġthe Ġlayout manager Ġis Ġstill Ġnull ") čĊĠĠĠĠĠĠĠ Ġ} čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġoverride Ġfun Ġon Pause () Ġ{ čĊĠĠĠĠĠĠĠ Ġsuper . on Pause () čĊĠĠĠĠĠĠĠ Ġval Ġbar H ider Ġ= Ġthis . activity Ġas ĠBar H ider čĊĠĠĠĠĠĠĠ Ġbar H ider . show Bar () čĊĠĠĠ Ġ} čĊčĊč Ċ }