Commit 3b2c5631 authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

Merge branch 'develop'

parents 155b1eae 6d289b10
......@@ -15,8 +15,8 @@ android {
minSdkVersion 19
targetSdkVersion 28
versionName "1.3.0"
versionCode 9
versionName "1.3.1"
versionCode 10
buildConfigField "String", "VERSION_UID", '"' + getBuildUid() + '"'
buildConfigField "String", "APP_DESCRIPTION", '"Gitfox is an Android client for Gitlab."'
......
......@@ -29,7 +29,9 @@ import ru.terrakok.gitlabclient.toothpick.provider.ApiProvider
import ru.terrakok.gitlabclient.toothpick.provider.GsonProvider
import ru.terrakok.gitlabclient.toothpick.provider.MarkDownConverterProvider
import ru.terrakok.gitlabclient.toothpick.provider.OkHttpClientProvider
import ru.terrakok.gitlabclient.toothpick.provider.OkHttpClientWithErrorHandlerProvider
import ru.terrakok.gitlabclient.toothpick.qualifier.ServerPath
import ru.terrakok.gitlabclient.toothpick.qualifier.WithErrorHandler
import toothpick.config.Module
/**
......@@ -41,6 +43,9 @@ class ServerModule(serverUrl: String) : Module() {
bind(String::class.java).withName(ServerPath::class.java).toInstance(serverUrl)
bind(Gson::class.java).toProvider(GsonProvider::class.java).providesSingletonInScope()
bind(OkHttpClient::class.java).toProvider(OkHttpClientProvider::class.java).providesSingletonInScope()
bind(OkHttpClient::class.java).withName(WithErrorHandler::class.java)
.toProvider(OkHttpClientWithErrorHandlerProvider::class.java)
.providesSingletonInScope()
bind(ProjectCache::class.java).singletonInScope()
bind(GitlabApi::class.java).toProvider(ApiProvider::class.java).providesSingletonInScope()
bind(MarkDownConverter::class.java).toProvider(MarkDownConverterProvider::class.java).providesSingletonInScope()
......
......@@ -9,6 +9,7 @@ import ru.terrakok.gitlabclient.model.data.cache.ProjectCache
import ru.terrakok.gitlabclient.model.data.server.ApiWithCache
import ru.terrakok.gitlabclient.model.data.server.GitlabApi
import ru.terrakok.gitlabclient.toothpick.qualifier.ServerPath
import ru.terrakok.gitlabclient.toothpick.qualifier.WithErrorHandler
import javax.inject.Inject
import javax.inject.Provider
......@@ -16,7 +17,7 @@ import javax.inject.Provider
* @author Konstantin Tskhovrebov (aka terrakok) on 20.06.17.
*/
class ApiProvider @Inject constructor(
private val okHttpClient: OkHttpClient,
@WithErrorHandler private val okHttpClient: OkHttpClient,
private val gson: Gson,
private val projectCache: ProjectCache,
@ServerPath private val serverPath: String
......
......@@ -22,12 +22,11 @@ class OkHttpClientProvider @Inject constructor(
) : Provider<OkHttpClient> {
override fun get() = with(OkHttpClient.Builder()) {
cache(Cache(context.cacheDir, 20 * 1024))
connectTimeout(30, TimeUnit.SECONDS)
readTimeout(30, TimeUnit.SECONDS)
cache(Cache(context.cacheDir, CACHE_SIZE_BYTES))
connectTimeout(TIMEOUT, TimeUnit.SECONDS)
readTimeout(TIMEOUT, TimeUnit.SECONDS)
addNetworkInterceptor(AuthHeaderInterceptor(authData))
addNetworkInterceptor(ErrorResponseInterceptor())
if (BuildConfig.DEBUG) {
addNetworkInterceptor(
HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY }
......@@ -36,4 +35,9 @@ class OkHttpClientProvider @Inject constructor(
}
build()
}
companion object {
private const val CACHE_SIZE_BYTES = 20 * 1024L
private const val TIMEOUT = 30L
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.toothpick.provider
import okhttp3.OkHttpClient
import ru.terrakok.gitlabclient.model.data.server.interceptor.ErrorResponseInterceptor
import javax.inject.Inject
import javax.inject.Provider
/**
* @author Myalkin Maxim (@MaxMyalkin) on 29.10.18.
*/
class OkHttpClientWithErrorHandlerProvider @Inject constructor(
private val client: OkHttpClient
) : Provider<OkHttpClient> {
override fun get() = client
.newBuilder()
.addNetworkInterceptor(ErrorResponseInterceptor())
.build()
}
\ No newline at end of file
......@@ -34,4 +34,7 @@ annotation class TodoListPendingState
annotation class UserId
@Qualifier
annotation class CacheLifetime
\ No newline at end of file
annotation class CacheLifetime
@Qualifier
annotation class WithErrorHandler
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment