package Ġlu cl x . com . be app . di . module Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroidx . room . Room Ċ import Ġdagger . Provides Ċ import Ġlu cl x . com . be app . data . local . App Database Ċ import Ġlu cl x . com . be app . data . local . dao . Card Dao Ċ import Ġlu cl x . com . be app . data . remote . ApiService Ċ import Ġlu cl x . com . be app . data . remote . Server Config Ċ 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 Ġjava . util . concurrent . TimeUnit Ċ import Ġjavax . inject . Singleton Ċ Ċ /** Ċ Ġ* ĠThe Ġapplication Ġmodule Ġwhich Ġprovides Ġapp Ġwide Ġinstances Ġof Ġvarious Ġcomponents Ċ Ġ**/ Ċ class ĠApp Module Ġ{ ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġfun Ġprovide Ok HttpClient (): ĠOk HttpClient Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġok HttpClient Builder Ġ= ĠOk HttpClient . Builder () ĊĠĠĠĠĠĠĠ Ġok HttpClient Builder . connect Timeout ( Server Config . SERVER _ TIMEOUT , ĠTimeUnit . MILLISECONDS ) ĊĠĠĠĠĠĠĠ Ġok HttpClient Builder . read Timeout ( Server Config . SERVER _ TIMEOUT , ĠTimeUnit . MILLISECONDS ) ĊĠĠĠĠĠĠĠ Ġok HttpClient Builder . write Timeout ( Server Config . SERVER _ TIMEOUT , ĠTimeUnit . MILLISECONDS ) ĊĠĠĠĠĠĠĠ Ġok HttpClient Builder . add Interceptor ( Http Logging Interceptor (). setLevel ( Http Logging Interceptor . Level . BASIC )) ĊĠĠĠĠĠĠĠ Ġreturn Ġok HttpClient Builder . build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġfun Ġprovide Ret rofit ( ok HttpClient : ĠOk HttpClient ): ĠApi Service Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġretrofit Ġ= ĠRet rofit . Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. baseUrl ( Server Config . SERVER _ HOST ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Converter Factory ( Gson Converter Factory . create ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. client ( ok HttpClient ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠĠĠ Ġreturn Ġretrofit . create ( ApiService :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġfun Ġprovide App Database ( application : ĠApplication ): ĠApp Database Ġ= ĊĠĠĠĠĠĠĠ ĠRoom . database Builder ( application , ĠApp Database :: class . java , Ġ" bee app . db "). build () ĊĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġfun Ġprovide Card Dao ( app Database : ĠApp Database ): ĠCard Dao Ġ= Ġapp Database . card Dao () Ċ }