{"id":18565092,"url":"https://github.com/jenly1314/mvvmframecomponent","last_synced_at":"2025-04-10T04:32:26.126Z","repository":{"id":72501416,"uuid":"274194244","full_name":"jenly1314/MVVMFrameComponent","owner":"jenly1314","description":":european_castle: 基于 MVVMFrame 框架 采用 JetPack (Lifecycle，LiveData，ViewModel，Room) + Dagger + DataBinding + Retrofit + OkHttp + Glide + Kotlin coroutines + ARouter等 为核心基础库构建的组件化方案","archived":false,"fork":false,"pushed_at":"2024-01-27T10:40:26.000Z","size":19241,"stargazers_count":26,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-01-27T12:34:45.588Z","etag":null,"topics":["android-com","architecture-components","arouter","component","component-architecture","components","dagger2","glide","hilt","jetpack","kotlin-coroutines","lifecycle","livedata","mvvm","mvvm-component","okhttp3","retrofit2","viewmodel"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jenly1314.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-06-22T16:52:49.000Z","updated_at":"2024-01-27T10:40:29.000Z","dependencies_parsed_at":"2024-01-27T12:41:33.806Z","dependency_job_id":null,"html_url":"https://github.com/jenly1314/MVVMFrameComponent","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenly1314%2FMVVMFrameComponent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenly1314%2FMVVMFrameComponent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenly1314%2FMVVMFrameComponent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenly1314%2FMVVMFrameComponent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jenly1314","download_url":"https://codeload.github.com/jenly1314/MVVMFrameComponent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223424334,"owners_count":17142747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-com","architecture-components","arouter","component","component-architecture","components","dagger2","glide","hilt","jetpack","kotlin-coroutines","lifecycle","livedata","mvvm","mvvm-component","okhttp3","retrofit2","viewmodel"],"created_at":"2024-11-06T22:17:44.187Z","updated_at":"2024-11-06T22:17:44.389Z","avatar_url":"https://github.com/jenly1314.png","language":"Kotlin","readme":"# MVVMFrameComponent\n\n![Image](app/src/main/ic_launcher-playstore.png)\n\n[![Download](https://img.shields.io/badge/download-App-blue.svg)](https://raw.githubusercontent.com/jenly1314/MVVMFrameComponent/master/app/release/app-release.apk)\n[![API](https://img.shields.io/badge/API-21%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=21)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/mit-license.php)\n\n基于 [MVVMFrame](https://github.com/jenly1314/MVVMFrame) 框架为核心基础库构建的组件化方案\n\n\n## 主要使用的核心技术\n\n* JetPack(Lifecycle，LiveData，ViewModel，Room，Hilt)\n* Dagger\n* DataBinding\n* Retrofit\n* OkHttp\n* Glide\n* Kotlin coroutines\n* ARouter\n\n## 架构\n\n**MVVMFrameComponent** 组件化架构图分层如下：\n\n![Architecture](art/MVVMFrameComponent_architecture.jpg)\n\n因为组件化的核心基础库是基于 **MVVMFrame**，这里贴出 **MVVMFrame** 的架构图如下：\n\n![Architecture](art/mvvm_architecture.jpg)\n\n## 浅谈组件化\n\n1. 什么是组件化？\n\u003e 组件化简单概括就是把一个功能完整的 **App** 或 **模块** 拆分成多个子模块, 让每个子模块可以独立编译和运行, 也可以作为 **library** 合并到宿主App组成一个完整的 **App**进行编译和运行。每个模块即可以不相互依赖，又可以相互交互。\n\n2. 为什么要组件化？\n\u003e 当一个项目随着时间的推移，需求不断的变更与迭代。各个模块也会变的相对复杂。维护难度也会随之增加，时间久了，可能会引起一些新的问题。这时我们就需要组件化。\n\n3. 组件化的优势是什么？\n\u003e 当一个App使用组件化开发方案时，主要的优势有：组件化拆分各个模块后，每个子模块都可以独立编译和运行，这样在开发调测某个模块时，可以大大提高编译速度和开发效率。多人开发时，每个人负责独立的模块，更有利于多人团队协作开发。并且各个模块之间的代码边界相对清晰，更易于后期维护。\n\n## MVVMFrameComponent 组件化方案\n\n**MVVMFrameComponent** = **MVVMFrame** + **Component**。即 **MVVMFrameComponent** 采用 **MVVM** 模式架构的组件化方案。\n\n\n## 工程各个 Module 相关说明\n\n### app\n宿主App：当各个子 **Module** 作为 **library** 时，则可将所有组件集成到 **宿主App** 中。此时 **宿主App** 则是一个拥有所有组件功能集合的完整的App。\n\n### common-base\n组件化公共基础库：主要包含 **MVVMFrame** 快速开发框架，和作为组件化的一些公共的核心基础库，方便快速构建组件化 **Project**。\n\n### common-res\n组件化公共资源库：主要方便统一管理各个 **Module** 中的一些公共资源相关。\n\n### module-joke\n一个简单的笑话功能模块：主要用来展示基于 **MVVMFrame** 来实现组件化开发，作为组件化开发的 **Module** 实现示例之一。\n\n### module-news\n一个简单的新闻功能模块：主要用来展示基于 **MVVMFrame** 来实现组件化开发，作为组件化开发的 **Module** 实现示例之一。\n\n## 其他\n\n### 特别说明\n**Project** -\u003e **build.gradle** 内的自定义变量 **isBuildModule**\n\u003e 自定义变量 **isBuildModule** 来统一管理各个子 module 方便在 **application** 与 **library** 之间进行切换\n\u003e\u003e 当 **isBuildModule = true** 时，表示 各个子 **module** 为 **application** ，即 **module** 可独立运行\n\u003e\u003e 当 **isBuildModule = false** 时，表示 各个子 **module** 为 **library** ，即 **module** 作为 **library** 合并到 **宿主App**\n\n**Project** -\u003e **module-build.gradle**\n\u003e 组件化子 **module** 通用 **build.gradle** ，方便统一管理\n\u003e\u003e 根据 **isBuildModule** 来统一管理各个子 **module** 在 **application** 与 **library** 之间切换\n\n\n### 关于 **MVVMFrame**\n因为 **MVVMFrameComponent** 的核心基础库是基于 **MVVMFrame** 的，所以需要对 **MVVMFrame** 有一定的了解，才能在使用 **MVVMFrameComponent** 时更加得心应手，\n这里不再特意介绍 **MVVMFrame** 相关的使用，具体介绍你可以直接查看 [MVVMFrame](https://github.com/jenly1314/MVVMFrame)\n\n## 示例\n\n### 关于各组件/模块共用 **Application** 初始化\n\n 对于模块公用的可以尽量写在 **BaseApp** 中，对于模块相对独立使用的，可以写在模块对应 **IComponentApp** 的实现实现类中。\n \n 特别说明：对于**IComponentApp** 的实现只是为你提供对应需求的一种解决方式，是可选的。根据需要使用。\n \n 这里贴出各模块的 **IComponentApp** 实现类示例供参考：\n \n [**module-joke**](module-joke) 中 **IComponentApp** 的实现类是 [**JokeComponentApp**](module-joke/src/main/java/com/king/mvvm/joke/JokeComponentApp.kt)\n \n [**module-news**](module-news) 中 **IComponentApp** 的实现类是 [**NewsComponentApp**](module-news/src/main/java/com/king/mvvm/news/NewsComponentApp.kt)\n\n下面是 [**module-joke**](module-joke) 中的代码示例\n```kotlin\nclass JokeComponentApp : IComponentApp{\n\n    override fun onCreate(app: BaseApp) {\n\n    }\n\n}\n```\n\n在 **Manifest** 中配置 **meta-data** 对应的**IComponentApp**实现类，示例如下 ：\n```xml\n        \u003c!-- name为：IComponentApp的实现类，value固定为: ComponentApp --\u003e\n        \u003cmeta-data android:name=\"com.king.mvvm.joke.JokeComponentApp\"\n            android:value=\"ComponentApp\"/\u003e\n```\n\n当想要获取各模块的 **IComponentApp** 实现类时，可通过 **BaseApp** 的 **getComponentApp** 方法获取。\n\n更多使用详情，请查看[app](app)中的源码使用示例\n\n## 更新日志 \n\n#### 2021-1-15\n*  使用Hilt简化Dagger依赖注入用法\n*  更新gradle至v4.1.1\n*  更新MVVMFrame至v2.0.0\n*  更新其它第三方依赖库版本\n\n#### 2020-6-23\n*  MVVMFrameComponent初始版本\n\n## 赞赏\n如果你喜欢MVVMFrameComponent，或感觉MVVMFrameComponent帮助到了你，可以点右上角“Star”支持一下，你的支持就是我的动力，谢谢 :smiley:\n\u003cp\u003e您也可以扫描下面的二维码，请作者喝杯咖啡 :coffee:\n\n\u003cdiv\u003e\n   \u003cimg src=\"https://jenly1314.github.io/image/page/rewardcode.png\"\u003e\n\u003c/div\u003e\n\n## 关于我\n\n| 我的博客                                                                                | GitHub                                                                                  | Gitee                                                                                  | CSDN                                                                                 | 博客园                                                                            |\n|:------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------|\n| \u003ca title=\"我的博客\" href=\"https://jenly1314.github.io\" target=\"_blank\"\u003eJenly's Blog\u003c/a\u003e | \u003ca title=\"GitHub开源项目\" href=\"https://github.com/jenly1314\" target=\"_blank\"\u003ejenly1314\u003c/a\u003e | \u003ca title=\"Gitee开源项目\" href=\"https://gitee.com/jenly1314\" target=\"_blank\"\u003ejenly1314\u003c/a\u003e  | \u003ca title=\"CSDN博客\" href=\"http://blog.csdn.net/jenly121\" target=\"_blank\"\u003ejenly121\u003c/a\u003e  | \u003ca title=\"博客园\" href=\"https://www.cnblogs.com/jenly\" target=\"_blank\"\u003ejenly\u003c/a\u003e  |\n\n## 联系我\n\n| 微信公众号        | Gmail邮箱                                                                          | QQ邮箱                                                                              | QQ群                                                                                                                       | QQ群                                                                                                                       |\n|:-------------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------|\n| [Jenly666](http://weixin.qq.com/r/wzpWTuPEQL4-ract92-R) | \u003ca title=\"给我发邮件\" href=\"mailto:jenly1314@gmail.com\" target=\"_blank\"\u003ejenly1314\u003c/a\u003e | \u003ca title=\"给我发邮件\" href=\"mailto:jenly1314@vip.qq.com\" target=\"_blank\"\u003ejenly1314\u003c/a\u003e | \u003ca title=\"点击加入QQ群\" href=\"https://qm.qq.com/cgi-bin/qm/qr?k=6_RukjAhwjAdDHEk2G7nph-o8fBFFzZz\" target=\"_blank\"\u003e20867961\u003c/a\u003e | \u003ca title=\"点击加入QQ群\" href=\"https://qm.qq.com/cgi-bin/qm/qr?k=Z9pobM8bzAW7tM_8xC31W8IcbIl0A-zT\" target=\"_blank\"\u003e64020761\u003c/a\u003e |\n\n\u003cdiv\u003e\n   \u003cimg src=\"https://jenly1314.github.io/image/page/footer.png\"\u003e\n\u003c/div\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenly1314%2Fmvvmframecomponent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjenly1314%2Fmvvmframecomponent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenly1314%2Fmvvmframecomponent/lists"}