File tree 3 files changed +5
-3
lines changed
app/src/main/java/com/wingsofts/gankclient
3 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import com.wingsofts.gankclient.di.component.ApiComponent
5
5
import com.wingsofts.gankclient.di.component.DaggerApiComponent
6
6
import com.wingsofts.gankclient.di.module.ApiModule
7
7
import com.wingsofts.gankclient.di.module.AppModule
8
- import retrofit2.Retrofit
9
8
import javax.inject.Inject
10
9
11
10
/* *
Original file line number Diff line number Diff line change @@ -3,10 +3,12 @@ package com.wingsofts.gankclient.di.component
3
3
import com.wingsofts.gankclient.App
4
4
import com.wingsofts.gankclient.di.module.ApiModule
5
5
import dagger.Component
6
+ import javax.inject.Singleton
6
7
7
8
/* *
8
9
* Created by wing on 16-11-23.
9
10
*/
11
+ @Singleton
10
12
@Component(modules = arrayOf(ApiModule ::class ))
11
13
interface ApiComponent {
12
14
Original file line number Diff line number Diff line change @@ -9,21 +9,21 @@ import dagger.Module
9
9
import dagger.Provides
10
10
import okhttp3.Cache
11
11
import okhttp3.HttpUrl
12
- import okhttp3.Interceptor
13
12
import okhttp3.OkHttpClient
14
13
import okhttp3.logging.HttpLoggingInterceptor
15
14
import retrofit2.Retrofit
16
15
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
17
16
import retrofit2.converter.gson.GsonConverterFactory
18
17
import rx.schedulers.Schedulers
19
18
import java.io.File
19
+ import javax.inject.Singleton
20
20
21
21
/* *
22
22
* Created by wing on 16-11-23.
23
23
*/
24
24
@Module(includes = arrayOf(AppModule ::class ))
25
25
class ApiModule {
26
- @Provides fun provideRetrofit (baseUrl : HttpUrl , client : OkHttpClient , gson : Gson ) =
26
+ @Provides @Singleton fun provideRetrofit (baseUrl : HttpUrl , client : OkHttpClient , gson : Gson ) =
27
27
Retrofit .Builder ()
28
28
.client(client)
29
29
.baseUrl(baseUrl)
@@ -33,6 +33,7 @@ class ApiModule {
33
33
34
34
@Provides fun provideBaseUrl () = HttpUrl .parse(" http://gank.io/api/" )
35
35
@Provides fun provideOkhttp (context : Context ,interceptor : HttpLoggingInterceptor ): OkHttpClient {
36
+ Log .d(" ddddd" ," new" )
36
37
val cacheSize = 1024 * 1024 * 10L
37
38
val cacheDir = File (context.cacheDir, " http" )
38
39
val cache = Cache (cacheDir, cacheSize)
You can’t perform that action at this time.
0 commit comments