Skip to content

limuyang2/glide-okcronet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

中文

glide-okcronet

A Glide network request library based on Cronet.

The network part is provided by okcronet.

Purpose

  • The official Cronet library provided by Glide does not enable HTTP3/QUIC support, which loses its advantages. Source code view CronetEngineSingleton
  • And it does not support customization of CronetEngine. The purpose of this library is to provide complete support.

Usage

First introduce the Cronet library:

//Import Cronet, this method is recommended in mainland China. You can also use other Cronet versions.
implementation("org.chromium.net:cronet-api:141.7340.3")
implementation("org.chromium.net:cronet-common:141.7340.3")
implementation("org.chromium.net:cronet-embedded:141.7340.3")

// Google Play uses this method
implementation("com.google.android.gms:play-services-cronet:18.1.1")

Method 1: Manual registration, using a custom CronetEngine (recommended)

It is recommended to use this method first, because you can reuse the global CronetEngine of the project.

Import

implementation("io.github.limuyang2:glide-okcronet:1.0.2")

Registration

Register in your project AppGlideModule.

@GlideModule
class DemoGlideModule : AppGlideModule() {
    
    override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
        /*
        Register the component using your own global CronetEngine.
         */
        registry.replace(
            GlideUrl::class.java, InputStream::class.java, OkCronetUrlLoader.Factory(App.cronetEngine)
        )
    }
}

Method 2: Automatic registration (not recommended)

This method will automatically generate a CronetEngine, which will not be reused with the one in the project.

Import

implementation("io.github.limuyang2:glide-okcronet-auto:1.0.0")

No manual registration is required.

About

🚀 A Glide network request library based on Cronet.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages