Skip to content

Commit 2dcbe05

Browse files
committed
Create README_cn.md
1 parent 8b937ce commit 2dcbe05

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README_cn.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Modularization Architecture Example
2+
3+
## Project Overview
4+
5+
This project demonstrates a modularization architecture based on Kotlin and Android. By using modularization, we can split an app into multiple independent modules, each of which can either be UI-related or non-UI-related, depending on the requirements. Components communicate via Services, achieving decoupling and increasing code reusability.
6+
7+
This architecture supports dynamic loading and unloading of components across different Activities, while also allowing communication between components via Services for flexible management and extension.
8+
9+
## Features
10+
11+
- **UI Modularization**: Each component can be related to UI, such as `TitleBar`, `Content`, and `BottomBar`, or non-UI functionality.
12+
- **Service Communication**: Components communicate via Services, achieving decoupling.
13+
- **Dynamic Loading & Management**: Components can be dynamically loaded, initialized, and destroyed, with management via a unified factory.
14+
- **Activity Lifecycle Management**: Components manage their lifecycle based on the Activity lifecycle to avoid memory leaks and resource wastage.
15+
## Architecture Design
16+
17+
### Core of Modularization Architecture
18+
19+
- **Component Class**: Each component extends the `Component` class, which manages the lifecycle and binds the Activity and View.
20+
- **Factory Class**: The `ComponentFactory` class is used to create and manage all component instances, providing a unified interface for retrieving, registering, and destroying components.
21+
- **Service Manager**: The `ServiceManager` class provides a mechanism for communication between components using Services.
22+
- **MainActivityDelegate**: The `MainActivityDelegate` class manages the creation, lifecycle, and destruction of components via delegation.
23+
24+
## How to Use
25+
26+
1. **Add Modules**: To add a new module, create a new class extending `Component` in the `modules/` directory.
27+
2. **Register Components**: Use the `ComponentFactory` to register and manage your components.
28+
3. **Service Communication**: To enable communication between components, use `ServiceManager` to send and receive messages.
29+
4. **Activity Integration**: Ensure that your components are integrated into the activity lifecycle through `MainActivityDelegate`.
30+
31+
## License
32+
33+
Copyright (c) [2024] [Andy]
34+
35+
Permission is hereby granted, free of charge, to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of this software, and to permit others to do so, subject to the following conditions:
36+
37+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software.
38+
39+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)