package Ġcom . sun il son . quiz creator . presentation . quiz Activity . fragments . quiz Fragment Ċ Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġcom . sun il son . quiz creator . R Ċ import Ġcom . sun il son . quiz creator . databinding . Fragment Quiz Binding Ċ import Ġcom . sun il son . quiz creator . presentation . main Activity . fragments . Base Fragment Ċ import Ġcom . sun il son . quiz creator . presentation . quiz Activity . Quiz Activity Ċ import Ġcom . sun il son . quiz creator . presentation . quiz Activity . Quiz ViewModel Ċ import Ġcom . sun il son . quiz creator . presentation . shared . Audio Service Ċ import Ġcom . sun il son . quiz creator . presentation . shared . extensions . show Toast Ċ import Ġkotlinx . android . synt hetic . main . fragment _ quiz . view .* Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠQu iz Fragment Ġ: ĠBase Fragment () Ġ{ ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġaudio Service : ĠAudio Service ĊĊĠĠĠ Ġval ĠviewModel : ĠQu iz ViewModel Ġby Ġlazy Ġ{ Ġ( activity !! Ġas ĠQu iz Activity ). quiz ViewModel Ġ} ĊĠĠĠ Ġvar Ġquiz Id : ĠString Ġ= Ġ"" ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= ĠData Binding Util . inflate < Fragment Quiz Binding >( in flater , ĠR . layout . fragment _ quiz , Ġcontainer , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġbinding . viewModel Ġ= ĠviewModel ĊĊĠĠĠĠĠĠĠ Ġdis posable . add ( viewModel . generate Quiz ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġarguments !!. getString (" selected Category "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġarguments !!. getBoolean (" shuffle Answers "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġarguments !!. getBoolean (" only Single "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġarguments !!. getInt (" max Question Amount ")). subscribe ({}, Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ?. show Toast ( it . message ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactivity !!. finish () ĊĠĠĠĠĠĠĠ Ġ})) ĊĊĠĠĠĠĠĠĠ Ġval Ġview Ġ= Ġbinding . root ĊĠĠĠĠĠĠĠ Ġview . quiz _ view . quiz Finished Callback Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdis posable . add ( viewModel . store Quiz (). subscribe ({ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ( activity Ġas ĠQu iz Activity ). show Result () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}, Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ( activity Ġas ĠQu iz Activity ). show Result () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ?. show Toast ( getString ( R . string . store _ quiz _ error )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ})) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġview . quiz _ view . audio Service Ġ= Ġaudio Service ĊĊĠĠĠĠĠĠĠ Ġreturn Ġview ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġnew Instance ( selected Category : ĠString ?, Ġshuffle Answers : ĠBoolean , Ġonly Single : ĠBoolean , Ġmax Question Amount : ĠInt ): ĠQu iz Fragment Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbundle Ġ= ĠBundle () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( selected Category Ġ!= Ġnull ) Ġbundle . putString (" selected Category ", Ġselected Category ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbundle . put Boolean (" only Single ", Ġonly Single ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbundle . put Boolean (" shuffle Answers ", Ġshuffle Answers ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbundle . put Int (" max Question Amount ", Ġmax Question Amount ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġfragment Ġ= ĠQu iz Fragment () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfragment . arguments Ġ= Ġbundle ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġfragment ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ }