package Ġaz . s if to sh ka . habit ube . di Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . SharedPreferences Ċ import Ġandroidx . room . Room Ċ import Ġaz . s if to sh ka . habit ube . data . model . PLAN N ED _ M IG RATION _ 1 _ 2 Ċ import Ġaz . s if to sh ka . habit ube . data . model . Pl anned Database Ċ import Ġaz . s if to sh ka . habit ube . data . model . WATCH ED _ M IG RATION _ 1 _ 2 Ċ import Ġaz . s if to sh ka . habit ube . data . model . W atched Database Ċ import Ġaz . s if to sh ka . habit ube . data . remote . Http Interceptor Ċ import Ġaz . s if to sh ka . habit ube . data . remote . Movie ApiService Ċ import Ġaz . s if to sh ka . habit ube . data . remote . O mdb ApiService Ċ import Ġaz . s if to sh ka . habit ube . data . repository .* Ċ import Ġaz . s if to sh ka . habit ube . domain . repository .* Ċ import Ġaz . s if to sh ka . habit ube . domain . util . Constants Ċ import Ġdagger . Module Ċ import Ġdagger . Provides Ċ import Ġdagger . h ilt . Install In Ċ import Ġdagger . h ilt . components . Singleton Component Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġokhttp 3 . logging . Http Logging Interceptor Ċ import Ġretrofit 2 . Ret rofit Ċ import Ġretrofit 2 . converter . gson . Gson Converter Factory Ċ import Ġjavax . inject . Named Ċ import Ġjavax . inject . Singleton Ċ Ċ /** Ċ Ġ* ĠThe ĠDI ĠModule Ġof Ġthe Ġentire Ġapplication . Ċ Ġ*/ Ċ @ Module Ċ @ Install In ( Singleton Component :: class ) Ċ object ĠApp Module Ġ{ ĊĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġfun Ġprovide Context ( application : ĠApplication ): ĠContext Ġ= Ġapplication . application Context ĊĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Named (" Movie Db ") ĊĠĠĠ Ġfun Ġprovide Ok HttpClient (): ĠOk HttpClient Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinterceptor Ġ= ĠHttp Interceptor () ĊĠĠĠĠĠĠĠ Ġval Ġhttp Interceptor Ġ= ĠHttp Logging Interceptor () ĊĠĠĠĠĠĠĠ Ġreturn ĠOk HttpClient ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Interceptor ( interceptor ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Interceptor ( http Interceptor . setLevel ( Http Logging Interceptor . Level . BASIC )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Named (" O MD b ") ĊĠĠĠ Ġfun Ġprovide O mdb Ok HttpClient (): ĠOk HttpClient Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠOk HttpClient ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Interceptor ( Http Logging Interceptor (). setLevel ( Http Logging Interceptor . Level . BASIC )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Named (" Movie Db ") ĊĠĠĠ Ġfun Ġprovide BaseUrl (): ĠString Ġ= ĠConstants . API _ URL ĊĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Named (" O MD b ") ĊĠĠĠ Ġfun Ġprovide O mdb Url (): ĠString Ġ= ĠConstants . OM DB _ API _ URL ĊĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Named (" Movie Db ") ĊĠĠĠ Ġfun Ġprovide Ret rofit (@ Named (" Movie Db ") Ġok HttpClient : ĠOk HttpClient , Ġ@ Named (" Movie Db ") Ġurl : ĠString ): ĠRet rofit Ġ= ĠRet rofit . Builder () ĊĠĠĠĠĠĠĠ Ġ. add Converter Factory ( Gson Converter Factory . create ()) ĊĠĠĠĠĠĠĠ Ġ. baseUrl ( url ) ĊĠĠĠĠĠĠĠ Ġ. client ( ok HttpClient ) ĊĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Named (" O MD b ") ĊĠĠĠ Ġfun Ġprovide O mdb Ret rofit (@ Named (" O MD b ") Ġok HttpClient : ĠOk HttpClient , Ġ@ Named (" O MD b ") Ġurl : ĠString ): ĠRet rofit Ġ= ĠRet rofit . Builder () ĊĠĠĠĠĠĠĠ Ġ. add Converter Factory ( Gson Converter Factory . create ()) ĊĠĠĠĠĠĠĠ Ġ. baseUrl ( url ) ĊĠĠĠĠĠĠĠ Ġ. client ( ok HttpClient ) ĊĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Named (" Movie Db ") ĊĠĠĠ Ġfun Ġprovide Movie ApiService (@ Named (" Movie Db ") Ġretrofit : ĠRet rofit ): ĠMovie ApiService Ġ= Ġretrofit . create ( Movie ApiService :: class . java ) ĊĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Named (" O MD b ") ĊĠĠĠ Ġfun Ġprovide O mdb ApiService (@ Named (" O MD b ") Ġretrofit : ĠRet rofit ): ĠO mdb ApiService Ġ= Ġretrofit . create ( O mdb ApiService :: class . java ) ĊĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġfun Ġprovide Movie DB Api Repository (@ Named (" Movie Db ") Ġservice : ĠMovie ApiService , Ġlocal Repository : ĠLocal Repository ): ĠMovie DB Api Repository Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠMovie DB Api Repository Impl ( service , Ġlocal Repository ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġfun Ġprovide O mdb Api Repository (@ Named (" O MD b ") Ġservice : ĠO mdb ApiService ): ĠO mdb Api Repository Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠO mdb Api Repository Impl ( service ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġfun Ġprovide Pl anned Database ( app : ĠApplication ): ĠPl anned Database Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠRoom . database Builder ( app , ĠPl anned Database :: class . java , ĠConstants . PLAN N ED ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Migrations ( PLAN N ED _ M IG RATION _ 1 _ 2 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġfun Ġprovide Pl anned Repository ( db : ĠPl anned Database ): ĠPl anned Repository Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠPl anned Repository Impl ( db . get Movie DAO (), Ġdb . get Show DAO ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġfun Ġprovide W atched Database ( app : ĠApplication ): ĠW atched Database Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠRoom . database Builder ( app , ĠW atched Database :: class . java , ĠConstants . WATCH ED ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Migrations ( WATCH ED _ M IG RATION _ 1 _ 2 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġfun Ġprovide W atched Repository ( db : ĠW atched Database ): ĠW atched Repository Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠW atched Repository Impl ( db . get Movie DAO (), Ġdb . get Show DAO ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġfun Ġprovide SharedPreferences ( app : ĠApplication ): ĠSharedPreferences Ġ= ĊĠĠĠĠĠĠĠ Ġapp . application Context . get SharedPreferences ( Constants . PRE FS _ NAME , ĠContext . MODE _ PRIVATE ) ĊĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġfun Ġprovide Local Repository ( preferences : ĠSharedPreferences ): ĠLocal Repository Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠLocal Repository Impl ( preferences ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġfun Ġprovide Realtime Repository (): ĠReal time Repository Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠReal time Repository Impl () ĊĠĠĠ Ġ} Ċ Ċ }