package Ġorg . w ats i . enrollment . device . repositories Ċ Ċ import Ġio . reactivex . Comp letable Ċ import Ġio . reactivex . Flow able Ċ import Ġio . reactivex . Single Ċ import Ġio . reactivex . schedul ers . Schedulers Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġorg . th reet en . bp . Clock Ċ import Ġorg . w ats i . enrollment . device . db . da os . Delta Dao Ċ import Ġorg . w ats i . enrollment . device . db . models . Delta Model Ċ import Ġorg . w ats i . enrollment . domain . entities . Delta Ċ import Ġorg . w ats i . enrollment . domain . repositories . Delta Repository Ċ Ċ class ĠDelta Repository Impl ( ĊĠĠĠ Ġprivate Ġval Ġdelta Dao : ĠDelta Dao , ĊĠĠĠ Ġprivate Ġval Ġclock : ĠClock , ĊĠĠĠ Ġprivate Ġval Ġok HttpClient : ĠOk HttpClient Ċ ) Ġ: ĠDelta Repository Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġun sync ed ( model Name : ĠDelta . ModelName ): ĠSingle < List < Delta >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġdelta Dao . un sync ed ( model Name ). map Ġ{ Ġdelta Models Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdelta Models . map Ġ{ Ġit . to Delta () Ġ} ĊĠĠĠĠĠĠĠ Ġ}. subscribe On ( Schedulers . io ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġmark As Sync ed ( delt as : ĠList < Delta >): ĠComp letable Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠComp letable . from Action Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdelta Dao . update ( delt as . map Ġ{ ĠDelta Model . from Delta ( it . copy ( sync ed Ġ= Ġtrue ), Ġclock ) Ġ}) ĊĠĠĠĠĠĠĠ Ġ}. subscribe On ( Schedulers . io ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġsync Status (): ĠFlow able < Delta Repository . Sync Status > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsync Flow ables Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdelta Dao . count Un sync ed ( Delta . ModelName . HO USE H OLD ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdelta Dao . count Un sync ed ( Delta . ModelName . HO USE H OLD _ EN ROLL MENT _ RECORD ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdelta Dao . count Un sync ed ( Delta . ModelName . MEMBER ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdelta Dao . count Un sync ed ( Delta . ModelName . MEMBER _ EN ROLL MENT _ RECORD ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdelta Dao . count Un sync ed ( Delta . ModelName . PH OTO ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdelta Dao . count Un sync ed ( Delta . ModelName . MEMBER SHIP _ PAYMENT ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġreturn ĠFlow able . combine Latest ( sync Flow ables ) Ġ{ Ġresults Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDelta Repository . Sync Status ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġun sync ed House holds Count Ġ= Ġresults [ 0 ] Ġas ĠInt , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġun sync ed House hold Enrollment Records Count Ġ= Ġresults [ 1 ] Ġas ĠInt , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġun sync ed Members Count Ġ= Ġresults [ 2 ] Ġas ĠInt , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġun sync ed Member Enrollment Records Count Ġ= Ġresults [ 3 ] Ġas ĠInt , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġun sync ed Photos Count Ġ= Ġresults [ 4 ] Ġas ĠInt , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġun sync ed Membership Payments Count Ġ= Ġresults [ 5 ] Ġas ĠInt ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġdelete All (): ĠComp letable Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠComp letable . from Action Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġok HttpClient . cache ()?. ev ict All () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdelta Dao . delete All () ĊĠĠĠĠĠĠĠ Ġ}. subscribe On ( Schedulers . io ()) ĊĠĠĠ Ġ} Ċ } Ċ