glide可以加载过期证书网站的图片

pull/1259/head
gedoor 3 years ago
parent 943a6401b5
commit 1f50b2ecfb
  1. 2
      app/src/main/java/io/legado/app/help/glide/OkHttpGlideModule.kt
  2. 5
      app/src/main/java/io/legado/app/help/glide/OkHttpModeLoaderFactory.kt
  3. 5
      app/src/main/java/io/legado/app/help/glide/OkHttpModelLoader.kt
  4. 5
      app/src/main/java/io/legado/app/help/glide/OkHttpStreamFetcher.kt

@ -15,7 +15,7 @@ class OkHttpGlideModule : AppGlideModule() {
registry.replace(
GlideUrl::class.java,
InputStream::class.java,
OkHttpModeLoaderFactory()
OkHttpModeLoaderFactory
)
}
}

@ -4,14 +4,13 @@ import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.load.model.ModelLoader
import com.bumptech.glide.load.model.ModelLoaderFactory
import com.bumptech.glide.load.model.MultiModelLoaderFactory
import io.legado.app.help.http.okHttpClient
import java.io.InputStream
class OkHttpModeLoaderFactory : ModelLoaderFactory<GlideUrl?, InputStream?> {
object OkHttpModeLoaderFactory : ModelLoaderFactory<GlideUrl?, InputStream?> {
override fun build(multiFactory: MultiModelLoaderFactory): ModelLoader<GlideUrl?, InputStream?> {
return OkHttpModelLoader(okHttpClient)
return OkHttpModelLoader
}
override fun teardown() {

@ -3,10 +3,9 @@ package io.legado.app.help.glide
import com.bumptech.glide.load.Options
import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.load.model.ModelLoader
import okhttp3.Call
import java.io.InputStream
class OkHttpModelLoader(private val client: Call.Factory) : ModelLoader<GlideUrl?, InputStream?> {
object OkHttpModelLoader : ModelLoader<GlideUrl?, InputStream?> {
override fun buildLoadData(
model: GlideUrl,
@ -14,7 +13,7 @@ class OkHttpModelLoader(private val client: Call.Factory) : ModelLoader<GlideUrl
height: Int,
options: Options
): ModelLoader.LoadData<InputStream?> {
return ModelLoader.LoadData(model, OkHttpStreamFetcher(client, model))
return ModelLoader.LoadData(model, OkHttpStreamFetcher(model))
}
override fun handles(model: GlideUrl): Boolean {

@ -7,6 +7,7 @@ import com.bumptech.glide.load.data.DataFetcher
import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.util.ContentLengthInputStream
import com.bumptech.glide.util.Preconditions
import io.legado.app.help.http.okHttpClient
import okhttp3.Call
import okhttp3.Request
import okhttp3.Response
@ -15,7 +16,7 @@ import java.io.IOException
import java.io.InputStream
class OkHttpStreamFetcher(private val client: Call.Factory, private val url: GlideUrl) :
class OkHttpStreamFetcher(private val url: GlideUrl) :
DataFetcher<InputStream>, okhttp3.Callback {
private var stream: InputStream? = null
private var responseBody: ResponseBody? = null
@ -29,7 +30,7 @@ class OkHttpStreamFetcher(private val client: Call.Factory, private val url: Gli
}
val request: Request = requestBuilder.build()
this.callback = callback
call = client.newCall(request)
call = okHttpClient.newCall(request)
call?.enqueue(this)
}

Loading…
Cancel
Save