From 0dfc1b3e6542b9deca6c56236b46e71e4c6976f5 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 23 Feb 2020 16:36:31 -0800 Subject: Remove singleton pattern for fbcookie --- app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/glide') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt index 537ad89c..1ae46c15 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt @@ -30,6 +30,8 @@ import com.pitchedapps.frost.facebook.FbCookie import okhttp3.Interceptor import okhttp3.OkHttpClient import okhttp3.Response +import org.koin.core.KoinComponent +import org.koin.core.inject /** * Created by Allan Wang on 28/12/17. @@ -63,10 +65,13 @@ class FrostGlideModule : AppGlideModule() { private fun getFrostHttpClient(): OkHttpClient = OkHttpClient.Builder().addInterceptor(FrostCookieInterceptor()).build() -class FrostCookieInterceptor : Interceptor { +class FrostCookieInterceptor : Interceptor, KoinComponent { + + private val fbCookie: FbCookie by inject() + override fun intercept(chain: Interceptor.Chain): Response { val origRequest = chain.request() - val cookie = FbCookie.webCookie ?: return chain.proceed(origRequest) + val cookie = fbCookie.webCookie ?: return chain.proceed(origRequest) val request = origRequest.newBuilder().addHeader("Cookie", cookie).build() return chain.proceed(request) } -- cgit v1.2.3