package Ġar . com . play 2 play . presentation . tr u co . lob by Ċ Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . fragment . app . activity ViewModels Ċ import Ġandroidx . fragment . app . view Models Ċ import Ġar . com . play 2 play . R Ċ import Ġar . com . play 2 play . databinding . Fragment Tr u co Server Build Teams Binding Ċ import Ġar . com . play 2 play . presentation . base game . Base Game Fragment Ċ import Ġar . com . play 2 play . presentation . tr u co . Tr u co ViewModel Ċ import Ġar . com . play 2 play . utils . from Html Ċ Ċ class ĠTr u co Build Teams Fragment Ġ: ĠBase Game Fragment < ĊĠĠĠĠĠĠĠ ĠFragment Tr u co Server Build Teams Binding , ĊĠĠĠĠĠĠĠ ĠL obby Event , ĊĠĠĠĠĠĠĠ ĠServer Tr u co Lobby ViewModel , ĊĠĠĠĠĠĠĠ ĠTr u co ViewModel >() Ġ{ ĊĊĠĠĠ Ġoverride Ġval Ġgame ViewModel : ĠTr u co ViewModel Ġby Ġactivity ViewModels () ĊĊĠĠĠ Ġoverride Ġval ĠviewModel : ĠServer Tr u co Lobby ViewModel Ġby Ġview Models () ĊĊĠĠĠ Ġoverride Ġval Ġgame Inflater : Ġ( LayoutInflater , ĠViewGroup ?, ĠBoolean ) Ġ-> ĠFragment Tr u co Server Build Teams Binding Ġ= ĊĠĠĠĠĠĠĠ ĠFragment Tr u co Server Build Teams Binding :: inflate ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġconnected Players Tr u co Adapter : ĠConnected Players Tr u co Adapter ĊĊĠĠĠ Ġoverride Ġfun Ġinit Values () Ġ{ ĊĠĠĠĠĠĠĠ Ġobserve ( game ViewModel . players ) Ġ{ ĠviewModel . set Players ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġobserve ( game ViewModel . total Players ) Ġ{ ĠviewModel . set Total Players ( it ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġinit UI () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . init UI () ĊĠĠĠĠĠĠĠ Ġsetup Players Grid () ĊĠĠĠĠĠĠĠ Ġgame Binding . help Order Players Description . text Ġ= Ġresources ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. getString ( R . string . tr _ lob by _ help _ order _ players ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. from Html () ĊĠĠĠĠĠĠĠ Ġgame Binding . start Game Button . setOnClickListener Ġ{ Ġgame ViewModel . start Game ( connected Players Tr u co Adapter . sorted Players ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġsetup Observer s () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . setup Observer s () ĊĠĠĠĠĠĠĠ Ġwith ( game ViewModel ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġobserve ( players ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconnected Players Tr u co Adapter . players Ġ= Ġit . to Mutable List () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . set Players ( it ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġobserve ( total Players ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconnected Players Tr u co Adapter . total Players Ġ= Ġit ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . set Total Players ( it ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġobserve ( viewModel . is Continue Button Enabled ) Ġ{ Ġgame Binding . start Game Button . isEnabled Ġ= Ġit Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsetup Players Grid () Ġ= Ġwith ( game Binding . players Grid ) Ġ{ ĊĠĠĠĠĠĠĠ Ġadapter Ġ= Ġactivity ?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠConnected Players Tr u co Adapter ( it ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. also Ġ{ Ġadapter Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġthis @ Tr u co Build Teams Fragment . connected Players Tr u co Adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Event ( event : ĠL obby Event ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( event ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠGo To Play Ġ-> ĠUnit ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġnew Instance () Ġ= ĠTr u co Build Teams Fragment () ĊĠĠĠ Ġ} Ċ } Ċ