package Ġcom . m orrow bone . ma fi ac ards . app . fragments Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . fragment . app . view Models Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġandroidx . recyclerview . widget . Grid LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . m orrow bone . ma fi ac ards . app . R Ċ import Ġcom . m orrow bone . ma fi ac ards . app . adapter . Default Deck Adapter Ċ import Ġcom . m orrow bone . ma fi ac ards . app . data .* Ċ import Ġcom . m orrow bone . ma fi ac ards . app . extensions . ids Ċ import Ġcom . m orrow bone . ma fi ac ards . app . utils . Injector Utils Ċ import Ġcom . m orrow bone . ma fi ac ards . app . view models . Base Deck ViewModel Ċ import Ġcom . pix p licity . eas yp refs . library . Prefs Ċ import Ġkotlinx . android . synt hetic . main . fragment _ default _ de cks .* Ċ Ċ class ĠDefault De cks Fragment Ġ: ĠBase M af ia Fragment () Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapter : ĠDefault Deck Adapter ĊĠĠĠ Ġprivate Ġval Ġde cks ViewModel Ġby Ġview Models < Base Deck ViewModel > Ġ{ ĊĠĠĠĠĠĠĠ ĠInject or Utils . provide Base ViewModel Factory ( require Context ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġinflater . inflate ( R . layout . fragment _ default _ de cks , Ġcontainer , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlast Player Count Ġ= ĠP refs . getInt ( LAST _ PLAYER _ COUNT , Ġ 6 ) ĊĠĠĠĠĠĠĠ Ġval Ġlayout Manager Ġ= ĠGrid LayoutManager ( require Context (), Ġ 3 ) ĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠDefault Deck Adapter ( mutable ListOf ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow Card Info Dialog ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġre cyclerView . adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠ Ġre cyclerView . layout Manager Ġ= Ġlayout Manager ĊĠĠĠĠĠĠĠ Ġre cyclerView . set Re cyc led View Pool ( recycler Pool ) ĊĊĠĠĠĠĠĠĠ Ġcounter View . min Value Ġ= ĠDeck Repository . MIS SED _ DEFAULT _ DE CK Ġ+ Ġ 1 ĊĠĠĠĠĠĠĠ Ġcounter View . max Value Ġ= ĠDeck Repository . DEFAULT _ DE CK S _ COUNT Ġ+ Ġcounter View . min Value ĊĠĠĠĠĠĠĠ Ġcounter View . card Count Ġ= Ġlast Player Count ĊĠĠĠĠĠĠĠ Ġcounter View . on Count Changed Listener Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġupdate ( Default Deck Dao . getDefault Deck ( it ) !! ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġupdate ( Default Deck Dao . getDefault Deck ( last Player Count ) !! ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġupdate ( deck : ĠDefault Deck ) Ġ{ ĊĠĠĠĠĠĠĠ Ġupdate Adapter ( deck . cards ) ĊĠĠĠĠĠĠĠ Ġsave _ btn . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġsh uffled Deck Ġ= ĠDeck ( Deck Repository . DEFAULT _ DE CK , Ġdeck . cards . ids ()). apply Ġ{ Ġshuffle () Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġde cks ViewModel . save Deck ( sh uffled Deck ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠP refs . put Int ( LAST _ PLAYER _ COUNT , Ġcounter View . card Count ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġdirection Ġ= ĠDefault De cks Fragment Directions . action Default De cks Fragment To Take Cards Fragment ( sh uffled Deck . deck Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfind Nav Controller (). navigate ( direction ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġupdate Adapter ( cards : ĠList < Default Card >) Ġ{ ĊĠĠĠĠĠĠĠ Ġadapter . update Cards ( cards ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠLAST _ PLAYER _ COUNT Ġ= Ġ" last _ player _ count " ĊĊĠĠĠĠĠĠĠ Ġval Ġre cycler Pool Ġ= ĠRecyclerView . Re cyc led View Pool (). apply Ġ{ Ġset Max Re cyc led Views ( 0 , Ġ 1 0 ) Ġ} ĊĠĠĠ Ġ} Ċ }