package Ġcom . h ern and aze ved o . mov ied b . data . datasource Ċ Ċ import Ġcom . h ern and aze ved o . mov ied b . Movie Ċ import Ġcom . h ern and aze ved o . mov ied b . data . api . interfaces . Api Repository Ċ import Ġcom . h ern and aze ved o . mov ied b . data . api . remote . Remote Movie Detail Ċ import Ġcom . h ern and aze ved o . mov ied b . data . api . remote . Remote Movie Search Ċ import Ġcom . h ern and aze ved o . mov ied b . data . dao . Movie Entity Dao Ċ import Ġcom . h ern and aze ved o . mov ied b . data . entity . Movie Entity Ċ import Ġcom . h ern and aze ved o . mov ied b . data . mapper . Movie Entity Mapper Ċ import Ġio . reactivex . Observable Ċ Ċ class ĠMovie DataSource Impl ( var Ġapi Repository : ĠApi Repository , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġvar Ġmovie Entity Dao : ĠMovie Entity Dao ) Ġ: ĠMovie DataSource Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġfind Movie By Title ( title : ĠString ): ĠObservable < Remote Movie Search > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġapi Repository . find Movie By Title ( title ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġfind Movie By I mdb Id ( imdb ID : ĠString ): ĠObservable < Remote Movie Detail > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġapi Repository . find Movie By I mdb Id ( imdb ID ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġfind Movie On Local Database By I mdb Id ( imdb ID : ĠString ): ĠMovie Entity Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġmovie Entity Dao . find Movie By I mdb ID ( imdb ID ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġsave Movie ToLocal Database ( movie : ĠMovie ): ĠObservable < Long > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠObservable . from Callable Ġ{ Ġmovie Entity Dao . insert Movie ( Movie Entity Mapper . transform To ( movie )) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġdelete Movie From Local Database ( imdb ID : ĠString ): ĠObservable < Long > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠObservable . from Callable Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmovie Entity Dao . delete Movie ( imdb ID ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn @ from Callable Ġ 1 L Ġ// ĠOne Ġrow Ġaffected ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġoverride Ġfun Ġfind Saved Movies On Local Database (): ĠObservable < List < Movie Entity >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġmovie Entity Dao . getAll Movies (). to Observable () ĊĠĠĠ Ġ} Ċ }