Glide threadPool and priority not working

32 views Asked by At

Scene:

I need show real progress when load image.

So i add AppGlideModule file in my project.

It's useful, I get real progress by 'addNetworkInterceptor()'.

But i noticed Glide threadPool and priority not working.

Actually, when i implementation("com.github.bumptech.glide:okhttp3-integration:4.11.0"),

even i delete AppGlideModule file ,Glide threadPool and priority still not working.

If i remove implementation("com.github.bumptech.glide:okhttp3-integration:4.11.0") and AppGlideModule file.

Glide threadPool and priority will working, but i lose real progress.

Here is code

build.grade:

   implementation 'com.github.bumptech.glide:glide:4.11.0'
    kapt 'com.github.bumptech.glide:compiler:4.11.0'

    implementation("com.github.bumptech.glide:okhttp3-integration:4.11.0") {
        exclude group: 'glide-parent'
    }

MyAppGlide:

@GlideModule
class MyAppGlide : AppGlideModule() {

    override fun isManifestParsingEnabled(): Boolean {
        return false
    }

    override fun applyOptions(context: Context, builder: GlideBuilder) {
        super.applyOptions(context, builder)
    }

    override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
        val executor: GlideExecutor = GlideExecutor.newSourceBuilder()
            .setThreadCount(1)
            .build()

        val client = OkHttpClient.Builder()
            .dispatcher(Dispatcher(executor))
            .addNetworkInterceptor { chain ->
                val request = chain.request()
                val response = chain.proceed(request)
                val listener = DispatchingProgressManager()
                response.newBuilder()
                    .body(ProgressResponseBody(request.url, response.body!!, listener))
                    .build()
            }
            .build()
        glide.registry.append(GlideUrl::class.java, InputStream::class.java, OkHttpUrlLoader.Factory(client))
    }

}
0

There are 0 answers