refactor: 引入 Kotlin 图片加载库 Coil 替代 Glide
This commit is contained in:
24
README.md
24
README.md
@ -100,7 +100,7 @@ android {
|
||||
* [OkHttp](https://github.com/square/okhttp):网络请求
|
||||
* [Retrofit](https://github.com/square/retrofit):网络请求
|
||||
* [MMKV](https://github.com/Tencent/MMKV):腾讯基于 **mmap** 内存映射的 **key-value** 本地存储组件
|
||||
* [Glide](https://github.com/bumptech/glide):快速高效的 **Android** 图片加载库
|
||||
* [Coil](https://github.com/coil-kt/coil):一个 Android 图片加载库,通过 Kotlin 协程的方式加载图片
|
||||
* [ARoute](https://github.com/alibaba/ARouter):阿里用于帮助 **Android App** 进行组件化改造的框架 —— 支持模块间的路由、通信、解耦
|
||||
* [BaseRecyclerViewAdapterHelper](https://github.com/CymChad/BaseRecyclerViewAdapterHelper):一个强大并且灵活的 **RecyclerViewAdapter**
|
||||
* [StatusBarUtil](https://github.com/laobie/StatusBarUtil):状态栏
|
||||
@ -370,4 +370,24 @@ fun test() {
|
||||
|
||||
目前官方文档还没有更新正式版的,还是 **alpha** 版本的文档:[使用 Hilt 实现依赖项注入](https://developer.android.com/training/dependency-injection/hilt-android)
|
||||
|
||||
**Dagger** 的 **Hilt** 文档目前是最新的:[Dagger-Hilt](https://dagger.dev/hilt/)
|
||||
**Dagger** 的 **Hilt** 文档目前是最新的:[Dagger-Hilt](https://dagger.dev/hilt/)
|
||||
|
||||
### Coil
|
||||
|
||||
**Coil **是一个 Android 图片加载库,通过 Kotlin 协程的方式加载图片。特点如下:
|
||||
|
||||
- **更快**: Coil 在性能上有很多优化,包括内存缓存和磁盘缓存,把缩略图存保存在内存中,循环利用 bitmap,自动暂停和取消图片网络请求等。
|
||||
- **更轻量级**: Coil 只有2000个方法(前提是你的 APP 里面集成了 OkHttp 和 Coroutines),Coil 和 Picasso 的方法数差不多,相比 Glide 和 Fresco 要轻量很多。
|
||||
- **更容易使用**: Coil 的 API 充分利用了 Kotlin 语言的新特性,简化和减少了很多样板代码。
|
||||
- **更流行**: Coil 首选 Kotlin 语言开发并且使用包含 Coroutines, OkHttp, Okio 和 AndroidX Lifecycles 在内最流行的开源库。
|
||||
|
||||
**Coil** 名字的由来:取 **Co**routine **I**mage **L**oader 首字母得来。
|
||||
|
||||
**资料:**
|
||||
|
||||
官方文档: [https://coil-kt.github.io/coil/](https://coil-kt.github.io/coil/)
|
||||
|
||||
三方库源码笔记(13)-可能是全网第一篇 Coil 的源码分析文章:[https://juejin.cn/post/6897872882051842061](https://juejin.cn/post/6897872882051842061)
|
||||
|
||||
【奇技淫巧】新的图片加载库?基于Kotlin协程的图片加载库——Coil:[https://juejin.cn/post/6844904159527829518](https://juejin.cn/post/6844904159527829518)
|
||||
|
||||
|
||||
@ -84,7 +84,6 @@ dependencies {
|
||||
androidTestImplementation DependencyConfig.AndroidX.TestEspresso
|
||||
implementation DependencyConfig.JetPack.HiltCore
|
||||
|
||||
kapt DependencyConfig.GitHub.GlideCompiler
|
||||
kapt DependencyConfig.GitHub.ARouteCompiler
|
||||
kapt DependencyConfig.GitHub.EventBusAPT
|
||||
kapt DependencyConfig.GitHub.AutoServiceAnnotations
|
||||
|
||||
@ -47,7 +47,6 @@ object DependencyConfig {
|
||||
const val Gson = "2.8.7" // Gson
|
||||
const val MMKV = "1.2.9" // 腾讯 MMKV 替代SP
|
||||
const val AutoSize = "1.2.1" // 屏幕适配
|
||||
const val Glide = "4.12.0" // Glide
|
||||
const val ARoute = "1.5.1" // 阿里路由
|
||||
const val ARouteCompiler = "1.5.1" // 阿里路由 APT
|
||||
const val RecyclerViewAdapter = "3.0.4" // RecyclerViewAdapter
|
||||
@ -56,6 +55,7 @@ object DependencyConfig {
|
||||
const val PermissionX = "1.4.0" // 权限申请
|
||||
const val LeakCanary = "2.7" // 检测内存泄漏
|
||||
const val AutoService = "1.0" // 自动生成SPI暴露服务文件
|
||||
const val Coil = "1.3.0" // Kotlin图片加载框架
|
||||
|
||||
// 第三方SDK--------------------------------------------------------------
|
||||
const val TencentBugly = "3.3.9" // 腾讯Bugly 异常上报
|
||||
@ -142,8 +142,6 @@ object DependencyConfig {
|
||||
const val Gson = "com.google.code.gson:gson:${Version.Gson}"
|
||||
const val MMKV = "com.tencent:mmkv-static:${Version.MMKV}"
|
||||
const val AutoSize = "me.jessyan:autosize:${Version.AutoSize}"
|
||||
const val Glide = "com.github.bumptech.glide:glide:${Version.Glide}"
|
||||
const val GlideCompiler = "com.github.bumptech.glide:compiler:${Version.Glide}"
|
||||
const val ARoute = "com.alibaba:arouter-api:${Version.ARoute}"
|
||||
const val ARouteCompiler = "com.alibaba:arouter-compiler:${Version.ARouteCompiler}"
|
||||
const val RecyclerViewAdapter =
|
||||
@ -156,6 +154,10 @@ object DependencyConfig {
|
||||
const val AutoService = "com.google.auto.service:auto-service:${Version.AutoService}"
|
||||
const val AutoServiceAnnotations =
|
||||
"com.google.auto.service:auto-service-annotations:${Version.AutoService}"
|
||||
const val Coil = "io.coil-kt:coil:${Version.Coil}"
|
||||
const val CoilGIF = "io.coil-kt:coil-gif:${Version.Coil}"
|
||||
const val CoilSVG = "io.coil-kt:coil-svg:${Version.Coil}"
|
||||
const val CoilVideo = "io.coil-kt:coil-video:${Version.Coil}"
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -41,7 +41,6 @@ dependencies {
|
||||
api DependencyConfig.GitHub.Gson
|
||||
api DependencyConfig.GitHub.MMKV
|
||||
api DependencyConfig.GitHub.AutoSize
|
||||
api DependencyConfig.GitHub.Glide
|
||||
api DependencyConfig.GitHub.ARoute
|
||||
api DependencyConfig.GitHub.RecyclerViewAdapter
|
||||
api DependencyConfig.GitHub.StatusBar
|
||||
@ -52,12 +51,15 @@ dependencies {
|
||||
api DependencyConfig.GitHub.OkHttpInterceptorLogging
|
||||
api DependencyConfig.GitHub.Retrofit
|
||||
api DependencyConfig.GitHub.RetrofitConverterGson
|
||||
api DependencyConfig.GitHub.Coil
|
||||
api DependencyConfig.GitHub.CoilGIF
|
||||
api DependencyConfig.GitHub.CoilSVG
|
||||
api DependencyConfig.GitHub.CoilVideo
|
||||
|
||||
api DependencyConfig.SDK.TencentBugly
|
||||
api DependencyConfig.SDK.TencentBuglyNative
|
||||
api DependencyConfig.SDK.TencentTBSX5
|
||||
|
||||
kapt DependencyConfig.GitHub.GlideCompiler
|
||||
kapt DependencyConfig.GitHub.ARouteCompiler
|
||||
kapt DependencyConfig.GitHub.EventBusAPT
|
||||
kapt DependencyConfig.GitHub.AutoServiceAnnotations
|
||||
|
||||
@ -28,7 +28,6 @@ dependencies {
|
||||
|
||||
api DependencyConfig.JetPack.HiltCore
|
||||
|
||||
kapt DependencyConfig.GitHub.GlideCompiler
|
||||
kapt DependencyConfig.GitHub.ARouteCompiler
|
||||
kapt DependencyConfig.GitHub.EventBusAPT
|
||||
kapt DependencyConfig.GitHub.AutoServiceAnnotations
|
||||
|
||||
Reference in New Issue
Block a user