Skip to content

Commit

Permalink
refactor retrofit module
Browse files Browse the repository at this point in the history
  • Loading branch information
pawlo2102 committed Oct 19, 2019
1 parent 8bbdb40 commit e83c0fd
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 40 deletions.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
10 changes: 10 additions & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,31 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/generated/not_namespaced_r_class_sources" />
<excludeFolder url="file://$MODULE_DIR$/build/generated/source/r" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotation_processor_list" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/apk_list" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-libraries" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/checkDebugClasspath" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compatible_screen_manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_merged_manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/processed_res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shader_assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split_list" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/kotlin" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 29 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
Expand Down
7 changes: 2 additions & 5 deletions retrofit/src/main/java/com/vrgsoft/retrofit/common/Auth.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.vrgsoft.retrofit.common

import okhttp3.Interceptor
import okhttp3.Response

interface Auth {
fun process(chain: Interceptor.Chain?): Response
abstract class Auth {
abstract fun createAuthHeaderString(): String
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ package com.vrgsoft.retrofit.common
import okhttp3.Interceptor
import okhttp3.Response

class AuthInterceptor(
internal class AuthInterceptor(
private val auth: Auth? = null
) : Interceptor {
override fun intercept(chain: Interceptor.Chain?): Response {
return auth?.process(chain) ?: chain!!.request()!!.newBuilder()?.let {
return chain?.request()?.newBuilder()?.let {
it.addHeader(HEADER_AUTHORIZATION, auth?.createAuthHeaderString() ?: "")
chain.proceed(it.build())
}!!
} ?: Response.Builder().build()
}

companion object {
private const val HEADER_AUTHORIZATION = "Authorization"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.vrgsoft.retrofit.common
import okhttp3.Interceptor
import okhttp3.Response

class HeaderInterceptor : Interceptor {
internal class HeaderInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain?): Response {
val builder = chain!!.request()!!.newBuilder()

Expand Down

0 comments on commit e83c0fd

Please sign in to comment.