package Ġcom . github . ap og nu . ot ter . repositories Ċ Ċ import Ġandroid . content . Context Ċ import Ġcom . github . ap og nu . ot ter . utils . F unk wh ale Response Ċ import Ġcom . github . ap og nu . ot ter . utils . Playlist Track Ċ import Ġcom . github . ap og nu . ot ter . utils . Playlist Tracks Cache Ċ import Ġcom . github . ap og nu . ot ter . utils . Playlist Tracks Response Ċ import Ġcom . github . kit tin un f . fuel . gson . gson Deserializer Of Ċ import Ġcom . google . gson . reflect . Type Token Ċ import Ġkotlinx . coroutines . flow . map Ċ import Ġkotlinx . coroutines . flow . toList Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġjava . io . BufferedReader Ċ Ċ class ĠPlaylist Tracks Repository ( override Ġval Ġcontext : ĠContext ?, Ġplaylist Id : ĠInt ) Ġ: ĠRepository < Playlist Track , ĠPlaylist Tracks Cache >() Ġ{ ĊĠ Ġoverride Ġval Ġcache Id Ġ= Ġ" tracks - playlist -$ playlist Id " ĊĠ Ġoverride Ġval Ġupstream Ġ= ĠHttp Upstream < Playlist Track , ĠF unk wh ale Response < Playlist Track >>( Http Upstream . Behavior . Single , Ġ"/ api / v 1 / play lists /$ playlist Id / tracks /? play able = true ", Ġobject Ġ: ĠType Token < Playlist Tracks Response >() Ġ{} . type ) ĊĊĠ Ġoverride Ġfun Ġcache ( data : ĠList < Playlist Track >) Ġ= ĠPlaylist Tracks Cache ( data ) ĊĠ Ġoverride Ġfun Ġun cache ( reader : ĠBufferedReader ) Ġ= Ġgson Deserializer Of ( Playlist Tracks Cache :: class . java ). deserialize ( reader ) ĊĊĠ Ġoverride Ġfun Ġon Data F etched ( data : ĠList < Playlist Track >): ĠList < Playlist Track > Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġval Ġfavor ites Ġ= ĠF avor ited Repository ( context ). fetch ( Origin . Network . origin ) ĊĠĠĠĠĠ Ġ. map Ġ{ Ġit . data Ġ} ĊĠĠĠĠĠ Ġ. toList () ĊĠĠĠĠĠ Ġ. flatten () ĊĊĠĠĠ Ġdata . map Ġ{ Ġtrack Ġ-> ĊĠĠĠĠĠ Ġtrack . track . favorite Ġ= Ġfavor ites . contains ( track . track . id ) ĊĠĠĠĠĠ Ġtrack ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ }