diff options
author | Allan Wang <me@allanwang.ca> | 2020-02-23 17:50:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-23 17:50:22 -0800 |
commit | 654cc6b943177120dc1a0a22a0d68d5cbfde2b5e (patch) | |
tree | 3bba2feb0cf99ae222693a4d564d9acf624322e2 /app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt | |
parent | 4d5aaf541dbfa7d521ebbc5f011a642c83c4b9c5 (diff) | |
parent | 1686de0d71d687990ca6f0d4b621bc4d52dee146 (diff) | |
download | frost-654cc6b943177120dc1a0a22a0d68d5cbfde2b5e.tar.gz frost-654cc6b943177120dc1a0a22a0d68d5cbfde2b5e.tar.bz2 frost-654cc6b943177120dc1a0a22a0d68d5cbfde2b5e.zip |
Merge pull request #1647 from AllanWang/kpref
Remove stateful singletons
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt | 9 |
1 files changed, 7 insertions, 2 deletions
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) } |