lan*_*nyf 6 android-glide android-module
构建库模块。在使用库模块的示例应用程序中
\n\n@GlideModule\nclass DPAppGlideModule : AppGlideModule() {\n override fun isManifestParsingEnabled(): Boolean {\n return false\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n并且在库模块中有:
\n\n@GlideModule\npublic final class LibGlideModule extends LibraryGlideModule {\n}\nRun Code Online (Sandbox Code Playgroud)\n\n在库模块中它使用 GlideApp 生成的 api
\n\nfun ImageView.loadImg(imageUrl: String) {\nvar requestOptions : RequestOptions = RequestOptions()\nrequestOptions.diskCacheStrategy(DiskCacheStrategy.ALL)\nif (!TextUtils.isEmpty(imageUrl)) {\n GlideApp.with(this.context)\n .setDefaultRequestOptions(requestOptions)\n .load(imageUrl)\n .into(this)\n}\nRun Code Online (Sandbox Code Playgroud)\n\n}
\n\n但由于这是库模块,不能与应用程序模块体面,所以无法编译
\n\n如何在库模块中使用GlideApp生成的api?
\n\n参考 \xe2\x80\x94 https://bumptech.github.io/glide/doc/configuration.html
\n只需添加
\nannotationProcessor com.github.bumptech.glide:compiler:4.8.0\nRun Code Online (Sandbox Code Playgroud)\n模块 gradle 文件中的依赖项。同步项目,然后清理并重建它。
\n如果您的模块使用 kotlin。将“annotationProcessor”更改为“kapt”。
\n如果您有其他模块依赖项\xef\xbc\x8c,请务必小心,确保使用正确的 GlideApp 对象。也许其他模块有自己的 GlideApp 对象
\n| 归档时间: |
|
| 查看次数: |
944 次 |
| 最近记录: |