package Ġcom . na ftar oz klad . present ers Ċ Ċ import Ġandroid . text . TextUtils Ċ import Ġcom . na ftar oz klad . business .* Ċ import Ġcom . na ftar oz klad . views . interfaces . Groups View Ċ import Ġjavax . inject . Inject Ċ Ċ /** Ċ Ġ* ĠCreated Ġby Ġbo hd an Ġon Ġ 1 0 / 4 / 1 7 Ċ Ġ*/ Ċ class ĠGroups Presenter Ġ@ Inject Ġconstructor ( Ċĉ ĉ private Ġval Ġgroups UseCase : ĠGroups UseCase , Ċĉ ĉ private Ġval Ġinit Cache UseCase : ĠInit Cache UseCase , Ċĉ ĉ private Ġval Ġsynchronize Groups UseCase : ĠSynchron ize Groups UseCase , Ċĉ ĉ private Ġval Ġsession UseCase : ĠSession UseCase Ċ ) Ġ: ĠPres enter < Groups View > Ġ{ ĊĊ ĉ late init Ġvar Ġgroups View : ĠGroups View ĊĊ ĉ override Ġfun Ġattach View ( view : ĠGroups View ) Ġ{ Ċĉ ĉ groups View Ġ= Ġview ĊĊĉ ĉ groups View . set Navigation Back Enabled (! TextUtils . isEmpty ( session UseCase . getCurrent GroupName ())) ĊĊĉ ĉ if Ġ(! init Cache UseCase . isInitialized ()) Ġ{ Ċĉĉ ĉ init Cache UseCase . init Internal Repo Ġ{ Ċĉĉĉ ĉ attach View ( groups View ) Ċĉĉ ĉ } ĊĊĉĉ ĉ return Ċĉ ĉ } ĊĊĉ ĉ groups View . set Group Selected Action Ġ{ ĠgroupId Ġ-> Ġgroups UseCase . getGroup ById ( groupId )?. let Ġ{ Ġsession UseCase . setCurrent GroupName ( it . name ) Ġ} Ġ} Ċĉ ĉ groups View . setText Changed Action Ġ{ Ġset List Items () Ġ} Ċĉ ĉ groups View . set Refresh Action Ġ{ Ġsynchronize Groups () Ġ} ĊĊĉ ĉ if Ġ( init Cache UseCase . is Groups Exist ()) Ġ{ Ċĉĉ ĉ set List Items () Ċĉĉ ĉ return Ċĉ ĉ } ĊĊĉ ĉ synchron ize Groups () Ċ ĉ } ĊĊ ĉ override Ġfun Ġdetach View () Ġ{} ĊĊ ĉ private Ġfun Ġsynchronize Groups () Ġ{ Ċĉ ĉ synchron ize Groups UseCase . synchron ize Groups ( object Ġ: ĠSynchron ize Callback Ġ{ Ċĉĉ ĉ override Ġfun ĠonSuccess () Ġ{ Ċĉĉĉ ĉ groups View . stop Refresh () Ċĉĉĉ ĉ set List Items () Ċĉĉ ĉ } ĊĊĉĉ ĉ override Ġfun ĠonError ( errorMessage : ĠString ) Ġ{ Ċĉĉĉ ĉ groups View . stop Refresh () Ċĉĉĉ ĉ groups View . onError ( errorMessage ) Ċĉĉ ĉ } Ċĉ ĉ }) Ċ ĉ } ĊĊ ĉ private Ġfun Ġset List Items () Ġ= Ġwith ( groups View ) Ġ{ Ċĉ ĉ set List Items ( groups UseCase . get Groups ( get Filter Text ())) Ċ ĉ } Ċ }