diff --git a/commonLib/build.gradle b/commonLib/build.gradle index 6477d38..bace06a 100644 --- a/commonLib/build.gradle +++ b/commonLib/build.gradle @@ -69,4 +69,11 @@ dependencies { //luban图片压缩 implementation rootProject.ext.dependencies.luban + + // glide + implementation rootProject.ext.dependencies.glide + // glide替换为OkHttp3代理请求 + implementation rootProject.ext.dependencies.gilde_integration + // glide注解 + kapt rootProject.ext.dependencies.annotationProcessor } \ No newline at end of file diff --git a/commonLib/proguard-rules.pro b/commonLib/proguard-rules.pro index 7f95977..049a104 100644 --- a/commonLib/proguard-rules.pro +++ b/commonLib/proguard-rules.pro @@ -129,3 +129,7 @@ public; public; } + +# 保留glide的配置类 +-keep public class * extends com.bumptech.glide.module.AppGlideModule +-keep class com.bumptech.glide.GeneratedAppGlideModuleImpl diff --git a/commonLib/src/main/AndroidManifest.xml b/commonLib/src/main/AndroidManifest.xml index 8b98006..8c78a06 100644 --- a/commonLib/src/main/AndroidManifest.xml +++ b/commonLib/src/main/AndroidManifest.xml @@ -3,4 +3,6 @@ package="com.common.commonlib"> + + \ No newline at end of file diff --git a/commonLib/src/main/java/com/common/commonlib/image/OkHttpLibGlideModule.kt b/commonLib/src/main/java/com/common/commonlib/image/OkHttpLibGlideModule.kt new file mode 100644 index 0000000..cb1ec7b --- /dev/null +++ b/commonLib/src/main/java/com/common/commonlib/image/OkHttpLibGlideModule.kt @@ -0,0 +1,22 @@ +package com.common.commonlib.image + +import android.content.Context +import com.bumptech.glide.Glide +import com.bumptech.glide.Registry +import com.bumptech.glide.annotation.GlideModule +import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader +import com.bumptech.glide.load.model.GlideUrl +import com.bumptech.glide.module.LibraryGlideModule +import java.io.InputStream + +@GlideModule +class OkHttpLibGlideModule : LibraryGlideModule() { + override fun registerComponents(context: Context, glide: Glide, registry: Registry) { + registry.replace( + GlideUrl::class.java, + InputStream::class.java, + OkHttpUrlLoader.Factory() + ) + super.registerComponents(context, glide, registry) + } +} \ No newline at end of file diff --git a/commonLibConfig.gradle b/commonLibConfig.gradle index e98bfc8..8a23e6f 100644 --- a/commonLibConfig.gradle +++ b/commonLibConfig.gradle @@ -33,7 +33,7 @@ ext { jxl : "2.6.12", navigation_fragment_ktx: "2.3.0", navigation_ui_ktx : "2.3.0", - glide : "4.11.0", + glide : "4.12.0", photo_view : "2.3.0", luban : "1.1.8", kotlin_android : "1.4.1" @@ -57,6 +57,7 @@ ext { navigation_ui_ktx : "androidx.navigation:navigation-ui-ktx:${versions.navigation_ui_ktx}", navigation_arg : "androidx.navigation:navigation-safe-args-gradle-plugin:${versions.navigation_ui_ktx}", glide : "com.github.bumptech.glide:glide:${versions.glide}", + gilde_integration : "com.github.bumptech.glide:okhttp3-integration:${versions.glide}", annotationProcessor : "com.github.bumptech.glide:compiler:${versions.glide}", photo_view : "com.github.chrisbanes:PhotoView:${versions.photo_view}", luban : "top.zibin:Luban:${versions.luban}"