package Ġcom . nik ol am . feature _ folders . folders _ overview . presenter Ċ Ċ import Ġcom . nik ol am . common . navigation . Nav Manager Ċ import Ġcom . nik ol am . feature _ folders . Folder Manager Ċ import Ġcom . nik ol am . feature _ folders . folder _ cho oser . presenter . Operation Mode Ċ import Ġcom . nik ol am . common . view model . Base Action Ċ import Ġcom . nik ol am . common . view model . Base ViewState Ċ import Ġtim ber . log . Tim ber Ċ Ċ internal Ġclass ĠFold ers Overview ViewModel Ġ( private Ġval Ġfolder Manager : ĠFolder Manager , Ġprivate Ġ Ġval Ġnav Manager : ĠNav Manager ) ĊĠĠĠ Ġ: Ġcom . nik ol am . common . view model . Base ViewModel < Folders Overview ViewModel . ViewState , ĠFold ers Overview ViewModel . Action >( ViewState ()){ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġsingle Book Folder : ĠHashSet < String > ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcollection Book Folder : ĠHashSet < String > ĊĠĠĠĠĊĠĠĠ Ġfun Ġstart Folder Chooser With Operation Mode ( operation Mode : ĠOperation Mode ){ ĊĠĠĠĠĠĠĠ Ġval Ġnav Directions Ġ= ĠFold ers Overview Fragment Directions . action Folders Overview Fragment To Folder Chooser Fragment ( operation Mode . toString ()) ĊĠĠĠĠĠĠĠ Ġnav Manager . navigate ( nav Directions ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġdelete Folder ( folder Ġ: ĠString ){ ĊĠĠĠĠĠĠĠ Ġfolder Manager . remove Folder ( folder ) ĊĠĠĠĠĠĠĠ Ġsingle Book Folder . remove ( folder ) ĊĠĠĠĠĠĠĠ Ġcollection Book Folder . remove ( folder ) ĊĠĠĠĠĠĠĠ Ġval Ġcombined Folders Ġ= Ġsingle Book Folder . plus ( collection Book Folder ) ĊĊĠĠĠĠĠĠĠ Ġsend Action ( Action . Files Loading Success ( Ġcombined Folders . toList ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Reduce State ( view Action : ĠAction ) Ġ= Ġwhen ( view Action ) Ġ{ ĊĠĠĠĠĠĠĠ Ġis ĠAction . Files Loading Success Ġ-> Ġstate . copy ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠisLoading Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Error Ġ Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfiles Ġ= Ġview Action . files ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġis ĠAction . Files Loading Failure Ġ-> Ġstate . copy ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠisLoading Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Error Ġ= Ġtrue , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfiles Ġ= ĠlistOf () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonLoad Data () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Load Data () ĊĠĠĠĠĠĠĠ Ġsingle Book Folder Ġ= ĠHashSet ( folder Manager . provide Book Single Folders ()) ĊĠĠĠĠĠĠĠ Ġcollection Book Folder Ġ= ĠHashSet ( folder Manager . provide Book Collection Folders ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġcombined Folders Ġ= Ġsingle Book Folder . plus ( collection Book Folder ) ĊĊĠĠĠĠĠĠĠ Ġsend Action ( Action . Files Loading Success ( Ġcombined Folders . toList ())) ĊĠĠĠ Ġ} ĊĠĠĠĠĊĠĠĠ Ġinternal Ġdata ĊĠĠĠ Ġclass ĠView State ( ĊĠĠĠĠĠĠĠ Ġval ĠisLoading : ĠBoolean Ġ= Ġtrue , ĊĠĠĠĠĠĠĠ Ġval Ġis Error : ĠBoolean Ġ= Ġfalse , ĊĠĠĠĠĠĠĠ Ġval Ġfiles Ġ: ĠList < String > Ġ= ĠlistOf () ĊĠĠĠ Ġ) Ġ: ĠBase ViewState ĊĊĠĠĠ Ġinternal Ġsealed Ġclass ĠAction Ġ: ĠBase Action Ġ{ ĊĠĠĠĠĠĠĠ Ġclass ĠFiles Loading Success ( val Ġfiles Ġ: ĠList < String >) Ġ: ĠAction () ĊĠĠĠĠĠĠĠ Ġobject ĠFiles Loading Failure Ġ: ĠAction () ĊĠĠĠ Ġ} Ċ }