diff options
author | Allan Wang <me@allanwang.ca> | 2018-04-13 00:13:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-13 00:13:28 -0400 |
commit | c5e769deabeb80d7257b85c5c3d802cf46e6b191 (patch) | |
tree | b3ac48678e893495b932c6500025db73a83e3d2b /app/src/main/kotlin/com/pitchedapps/frost/glide | |
parent | d9e2562267e549ee407e683262406581f2c4888e (diff) | |
download | frost-c5e769deabeb80d7257b85c5c3d802cf46e6b191.tar.gz frost-c5e769deabeb80d7257b85c5c3d802cf46e6b191.tar.bz2 frost-c5e769deabeb80d7257b85c5c3d802cf46e6b191.zip |
Fix view full image (#882)v2.0.1
* Test including full photo viewer
* Test cookie in glide
* Fix parser and add redirects to view full image
* Update changelog
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/glide')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt | 21 |
1 files changed, 21 insertions, 0 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 651e57d8..50d4d7b4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt @@ -10,6 +10,11 @@ import com.bumptech.glide.load.resource.bitmap.BitmapTransformation import com.bumptech.glide.load.resource.bitmap.CircleCrop import com.bumptech.glide.module.AppGlideModule import com.bumptech.glide.request.RequestOptions +import com.pitchedapps.frost.facebook.FbCookie +import com.pitchedapps.frost.utils.L +import okhttp3.Interceptor +import okhttp3.OkHttpClient +import okhttp3.Response /** * Created by Allan Wang on 28/12/17. @@ -35,6 +40,22 @@ fun <T> RequestBuilder<T>.transform(vararg transformation: BitmapTransformation) class FrostGlideModule : AppGlideModule() { override fun registerComponents(context: Context, glide: Glide, registry: Registry) { +// registry.replace(GlideUrl::class.java, +// InputStream::class.java, +// OkHttpUrlLoader.Factory(getFrostHttpClient())) // registry.prepend(HdImageMaybe::class.java, InputStream::class.java, HdImageLoadingFactory()) } +} + +private fun getFrostHttpClient(): OkHttpClient = + OkHttpClient.Builder().addInterceptor(FrostCookieInterceptor()).build() + +class FrostCookieInterceptor : Interceptor { + override fun intercept(chain: Interceptor.Chain): Response { + val origRequest = chain.request() + val cookie = FbCookie.webCookie ?: return chain.proceed(origRequest) + L.v { "Add cookie to req $cookie" } + val request = origRequest.newBuilder().addHeader("Cookie", cookie).build() + return chain.proceed(request) + } }
\ No newline at end of file |