package Ġcom . tom sz om . smo g app . city Ċ Ċ import Ġcom . tom sz om . smo g app . city . measure . Measure ViewModel Ċ import Ġcom . tom sz om . smo g app . model . Sensor Ċ import Ġcom . tom sz om . smo g app . model . Sensor Data Ċ import Ġcom . tom sz om . smo g app . network . Network Rest Adapter Ċ import Ġio . reactivex . Observable Ċ import Ġio . reactivex . Single Ċ Ċ /** Ċ Ġ* ĠCreated Ġby Ġt sm Ġon Ġ 0 3 / 0 4 / 2 0 1 8 Ċ Ġ*/ Ċ class ĠCity Provider Ġ: ĠCity Contract . Provider Ġ{ ĊĠĠĠ Ġprivate Ġval Ġair Quality Service Ġ= ĠNetwork Rest Adapter (). create G ios Air Quality Service () ĊĊĠĠĠ Ġoverride Ġfun Ġget Measures ( station Id : ĠLong ): ĠSingle < List < Measure ViewModel >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠgetS ensors ( station Id ). flatMap Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠObservable . from Iterable ( it ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map ( this :: meas ures From Sensor ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. toList () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠgetS ensors ( station Id : ĠLong ): ĠSingle < List < Sensor >> Ġ= Ġair Quality Service . getS ensors ( station Id . toString ()) ĊĊĠĠĠ Ġprivate Ġfun Ġmeasures From Sensor ( sensor : ĠSensor ): ĠMeasure ViewModel Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsensor Data Ġ= Ġget Sensor Data ( sensor . id ). to Observable (). blocking First () ĊĠĠĠĠĠĠĠ Ġreturn ĠMeasure ViewModel ( sensor . param . param Formula , Ġsensor Data . values . filter Ġ{ Ġit . value Ġ!= Ġnull Ġ}. sorted By Ġ{ Ġit . date Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Sensor Data ( sensor Id : ĠLong ): ĠSingle < Sensor Data > Ġ= Ġair Quality Service . get Sensor Data ( sensor Id . toString ()) Ċ Ċ }