package Ġcom . example . android weather . repository Ċ Ċ import Ġcom . example . android weather . db . City Ċ import Ġcom . example . android weather . db . City Dao Ċ import Ġio . reactivex . rx java 3 . core . Observable Ċ import Ġio . reactivex . rx java 3 . schedul ers . Schedulers Ċ import Ġjava . util . Calendar Ċ import Ġjavax . inject . Inject Ċ import Ġjavax . inject . Singleton Ċ Ċ @ Singleton Ċ class ĠSearch History Repository Ġ@ Inject Ġconstructor ( private Ġval Ġcity Dao : ĠCity Dao ) Ġ{ ĊĊĠ Ġfun ĠgetLast Se ar ched City (): ĠObservable < City > Ġ{ ĊĠĠĠ Ġreturn Ġcity Dao . getLast Se ar ched City (). to Observable (). subscribe On ( Schedulers . io ()) ĊĠ Ġ} ĊĊĠ Ġfun Ġget Search History (): ĠObservable < List < City >> Ġ{ ĊĠĠĠ Ġreturn Ġcity Dao . getAll (). to Observable (). subscribe On ( Schedulers . io ()) ĊĠ Ġ} ĊĊĠ Ġfun Ġinsert ( id : ĠInt , Ġname : ĠString ) Ġ{ ĊĠĠĠ Ġcity Dao . insert ( ĊĠĠĠĠĠ ĠCity ( ĊĠĠĠĠĠĠĠ Ġid Ġ= Ġid , ĊĠĠĠĠĠĠĠ Ġname Ġ= Ġname , ĊĠĠĠĠĠĠĠ Ġlast Se ar ched At Ġ= ĠCalendar . getInstance (). time In Millis ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġfun Ġremove ( id : ĠInt ): ĠObservable < Int > Ġ{ ĊĠĠĠ Ġreturn Ġcity Dao . delete City ById ( id ). to Observable (). subscribe On ( Schedulers . io ()) ĊĠ Ġ} Ċ }