https://github.com/limuyang2/glide-okcronet
π A Glide network request library based on Cronet.
https://github.com/limuyang2/glide-okcronet
Last synced: 2 months ago
JSON representation
π A Glide network request library based on Cronet.
- Host: GitHub
- URL: https://github.com/limuyang2/glide-okcronet
- Owner: limuyang2
- License: mit
- Created: 2024-03-28T09:06:19.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-29T03:12:51.000Z (about 1 year ago)
- Last Synced: 2025-03-26T00:51:19.793Z (3 months ago)
- Language: Kotlin
- Homepage:
- Size: 107 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[δΈζ](https://github.com/limuyang2/glide-okcronet/blob/main/README_CN.md)
# glide-okcronet
A Glide network request library based on Cronet.The network part is provided by [okcronet](https://github.com/limuyang2/okcronet).
# Purpose
* The official Cronet library provided by Glide does not enable HTTP3/QUIC support, which loses its advantages. Source code view [CronetEngineSingleton](https://github.com/bumptech/glide/blob/master/integration/cronet/src/main/java/com/bumptech/glide/integration/cronet/CronetEngineSingleton.java)
* And it does not support customization of CronetEngine. The purpose of this library is to provide complete support.# Usage
First introduce the Cronet library:
```groovy
//Import Cronet, this method is recommended in mainland China. You can also use other Cronet versions.
implementation("org.chromium.net:cronet-api:119.6045.31")
implementation("org.chromium.net:cronet-common:119.6045.31")
implementation("org.chromium.net:cronet-embedded:119.6045.31")// Google Play uses this method
implementation("com.google.android.gms:play-services-cronet:18.0.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
```kotlin
implementation("io.github.limuyang2:glide-okcronet:1.0.1")
```### Registration
Register in your project AppGlideModule.
```kotlin
@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
```kotlin
implementation("io.github.limuyang2:glide-okcronet-auto:1.0.0")
```
No manual registration is required.