{"id":14979948,"url":"https://github.com/meituan-dianping/shield","last_synced_at":"2025-04-04T10:05:27.938Z","repository":{"id":78188212,"uuid":"113555063","full_name":"Meituan-Dianping/Shield","owner":"Meituan-Dianping","description":"A declarative, efficient, and flexible Native framework for building user interfaces. ","archived":false,"fork":false,"pushed_at":"2019-01-30T03:38:16.000Z","size":507,"stargazers_count":948,"open_issues_count":8,"forks_count":114,"subscribers_count":46,"default_branch":"master","last_synced_at":"2025-04-04T09:43:15.080Z","etag":null,"topics":["android","gradle","module"],"latest_commit_sha":null,"homepage":"","language":"Java","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/Meituan-Dianping.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}},"created_at":"2017-12-08T09:10:42.000Z","updated_at":"2025-03-31T11:07:47.000Z","dependencies_parsed_at":"2023-03-12T03:43:49.491Z","dependency_job_id":null,"html_url":"https://github.com/Meituan-Dianping/Shield","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/Meituan-Dianping%2FShield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meituan-Dianping%2FShield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meituan-Dianping%2FShield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meituan-Dianping%2FShield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Meituan-Dianping","download_url":"https://codeload.github.com/Meituan-Dianping/Shield/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157281,"owners_count":20893220,"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","gradle","module"],"created_at":"2024-09-24T14:00:59.130Z","updated_at":"2025-04-04T10:05:27.908Z","avatar_url":"https://github.com/Meituan-Dianping.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shield\n\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Meituan-Dianping/Shield/pulls)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Meituan-Dianping/Shield/blob/master/LICENSE)\n\n## 概述\n\n`Shield`是一个模块化UI界面解决方案，它不仅仅是一个Native（Android\u0026iOS）的UI开发框架，而是美团点评到店综合团队基于自身复杂的业务场景沉淀出来的UI开发最佳实践，它不但具备高可复用性，协同开发等特性，还包括后端动态配置，动态模块等一系列解决方案。\n\n## 接入\n在工程的`build.gradle`文件中添加依赖：\n```\ncompile 'com.dianping.android.sdk:shieldCore:1.6.0'\n```\n\n## 设计思想\n\n### 1.模块独立\n\n模块具备完整的页面能力（生命周期，Context等），模块可以在不同的页面中自由组合，模块与页面高度解耦，模块不关心具体在哪个页面中运行。模块之间需要解耦，模块只关心自己涉及的状态和数据。\n\n### 2.数据驱动\n模块的表现只取决于所依赖的数据，而与具体的行为无关。\n\n### 3.接口\n整个模块化框架通过抽象接口进行交互，通过接口规范行为，通过接口的不同实现达到多态的目的\n\n## 整体框架\n\n一个典型的模块化页面主要由页面和多个模块构成。页面通过模块配置（Config）确定加载哪些模块构成页面。模块又分为业务逻辑（Agent）和视图逻辑部分（SectionCellInterface， 包括 Section 和 Row）。\n页面包含两个管理器，模块管理器（AgentManager）和视图管理器（CellManager）。其中模块管理器决定了如何创建，更新，恢复及销毁模块以及如何将模块添加到页面中；\n视图管理器则决定了页面使用何种视图容器管理视图以及模块中的视图组件（SectionCellInterface）如何添加到视图容器中。\n除此之外，页面还持有一个支持数据订阅和通知的白板（WhiteBoard），用于模块与页面，模块与模块之间的数据交互。\n\n## 接入\n请参照Sample中的com.example.shield.fragments.AgentManagerFragment\n\n另外：\n\n1. 在onCreateView中构建页面容器ContentView。\n2. 在onActivityCreated方法中调用setAgentContainerView方法设置模块容器。\n3. 在getCellManager方法中指定页面使用何种CellManager（默认为SectionRecyclerCellManager,与RecyclerView容器配合使用）。\n4. 在getAgentManager方法中指定页面使用何种AgentManager（默认为LightAgentManager，一般无需定制）。\n5. 通过generaterDefaultConfigAgentList方法指定模块配置。\n\n## 博客文章\n[Shield——开源的移动端页面模块化开发框架](https://tech.meituan.com/shield_opensource.html)\n\n## 技术支持\n- 通过提交issue来寻求帮助\n- 联系我们寻求帮助\n\n## ChangeLog\n[2018.3.12]\n-   RecyclerView容器支持设置是否可以滚动\n-   HeaderCell\u0026FooterCell新增置顶置底支持\n-   HeaderCell\u0026FooterCell新增上下分割线完善\n-   优化模块配置方式\n-   优化模块曝光计算逻辑\n-   Bug Fix\n\n[2019.1.30]\n- 基于Kotlin的全面重构\n- 新的视图管理器ShieldNodeCellManager\n- 新的生命周期路由ShieldLifeCycler\n- 新的ShieldSectionCellItem视图层表达方式\n- Bugfix\n\n## 贡献代码\n- 欢迎提交issue\n- 欢迎提交PR\n\n## LICENSE\n\nShield is [MIT licensed](https://github.com/Meituan-Dianping/Shield/blob/master/LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeituan-dianping%2Fshield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeituan-dianping%2Fshield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeituan-dianping%2Fshield/lists"}