package Ġdata . t inder . recommend ation Ċ Ċ import Ġandroid . content . Context Ċ import Ġcom . ny times . android . external . fs 3 . FileSystem Record Pers ister Ċ import Ġcom . ny times . android . external . fs 3 . filesystem . FileSystem Factory Ċ import Ġcom . ny times . android . external . store 3 . base . Fetcher Ċ import Ġcom . ny times . android . external . store 3 . base . impl . Fluent Memory Policy Builder Ċ import Ġcom . ny times . android . external . store 3 . base . impl . Fluent Store Builder . Companion . parsed With Key Ċ import Ġcom . ny times . android . external . store 3 . base . impl . St ale Policy Ċ import Ġcom . ny times . android . external . store 3 . base . impl . Store Ċ import Ġcom . ny times . android . external . store 3 . middleware . mos hi . M oshi Parser Factory Ċ import Ġcom . squareup . mos hi . M oshi Ċ import Ġcom . squareup . mos hi . adapters . R fc 3 3 3 9 Date Json Adapter Ċ import Ġdagger . Module Ċ import Ġdagger . Provides Ċ import Ġdata . crash . Crash Reporter Module Ċ import Ġdata . network . Parser Module Ċ import Ġdata . t inder . T inder Api Ċ import Ġdata . t inder . T inder Api Module Ċ import Ġok io . Buffered Source Ċ import Ġreporter . Crash Reporter Ċ import Ġjava . util . Date Ċ import Ġjava . util . concurrent . TimeUnit Ċ import Ġjavax . inject . Singleton Ċ import Ġdagger . Lazy Ġas ĠD agger Lazy Ċ Ċ @ Module ( includes Ġ= Ġ[ ĊĠ ĠParser Module :: class , ĠT inder Api Module :: class , ĠCrash Reporter Module :: class ]) Ċ internal Ġclass ĠRecommend ation Source Module Ġ{ ĊĠ Ġ@ Provides ĊĠ Ġ@ Singleton ĊĠ Ġfun Ġstore ( context : ĠContext , Ġm oshi Builder : ĠM oshi . Builder , Ġapi : ĠT inder Api ) Ġ= ĊĠĠĠĠĠ Ġparsed With Key < Unit , ĠBuffered Source , ĠRecommend ation Response >( ĊĠĠĠĠĠĠĠĠĠ ĠFetch er Ġ{ Ġfetch ( api ) Ġ}) Ġ{ ĊĠĠĠĠĠĠĠ Ġparsers Ġ= ĠlistOf ( M oshi Parser Factory . create Source Parser ( mos hi Builder ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add ( Date :: class . java , ĠR fc 3 3 3 9 Date Json Adapter (). null Safe ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRecommend ation Response :: class . java )) ĊĠĠĠĠĠĠĠ Ġmemory Policy Ġ= ĠFluent Memory Policy Builder . build Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġexpire After TimeUnit Ġ= ĠTimeUnit . MILLISECONDS ĊĠĠĠĠĠĠĠĠĠ Ġexpire After Write Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġpers ister Ġ= ĠFileSystem Record Pers ister . create ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠFileSystem Factory . create ( context . external Cache Dir Ġ?: Ġcontext . cacheDir !! ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ{ Ġit . toString () Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠ 7 , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTimeUnit . DAYS ) ĊĠĠĠĠĠĠĠ Ġstale Policy Ġ= ĠSt ale Policy . NETWORK _ BEFORE _ ST ALE ĊĠĠĠĠĠ Ġ} ĊĊĠ Ġ@ Provides ĊĠ Ġ@ Singleton ĊĠ Ġfun Ġsource ( store : ĠD agger Lazy < Store < Recommendation Response , ĠUnit >>, ĊĠĠĠĠĠĠĠĠĠĠĠĠ Ġcrash Reporter : ĠCrash Reporter ) Ġ= ĠGet Recommendation Source ( store , Ġcrash Reporter ) ĊĊĠ Ġprivate Ġfun Ġfetch ( api : ĠT inder Api ) Ġ= Ġapi . get Recommend ations (). map Ġ{ Ġit . source () Ġ} Ċ } Ċ