perf:check GlideUrl cacheKey before call AnalyzeUrl

pull/1786/head
Xwite 3 years ago
parent a327d6d53a
commit 69dfea0218
  1. 7
      app/src/main/java/io/legado/app/help/glide/OkHttpModelLoader.kt

@ -5,6 +5,7 @@ import com.bumptech.glide.load.Options
import com.bumptech.glide.load.model.GlideUrl import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.load.model.ModelLoader import com.bumptech.glide.load.model.ModelLoader
import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.utils.isAbsUrl
import java.io.InputStream import java.io.InputStream
@ -19,7 +20,11 @@ object OkHttpModelLoader : ModelLoader<GlideUrl?, InputStream?> {
height: Int, height: Int,
options: Options options: Options
): ModelLoader.LoadData<InputStream?> { ): ModelLoader.LoadData<InputStream?> {
val modelWithHeader = AnalyzeUrl(model.toString()).getGlideUrl() val cacheKey = model.toString()
var modelWithHeader = model
if (cacheKey.isAbsUrl()) {
modelWithHeader = AnalyzeUrl(cacheKey).getGlideUrl()
}
return ModelLoader.LoadData(modelWithHeader, OkHttpStreamFetcher(modelWithHeader, options)) return ModelLoader.LoadData(modelWithHeader, OkHttpStreamFetcher(modelWithHeader, options))
} }

Loading…
Cancel
Save