# communication **Repository Path**: musiccrazy/communication ## Basic Information - **Project Name**: communication - **Description**: 页面之间的通信框架 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: fenzhi - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-10-08 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # communication #### 介绍 页面之间的通信框架 优点:简便轻量型、速度快、易维护、可拿返回值 缺点:单处接收 1. 页面之间的通信,(Activity之间 或者 fragment之间 或者 Activity与fragment之间) 2. 使用可以带参数和拿到返回值,(EventBus没有返回值) 3. 设置事件 FunctionManager.getInstans().addFunction(function); 传入的function可以是以下几种: FunctionNoParamNoResult:不带参数和返回值 FunctionWithParamOnly:只带参数 FunctionWithParamBouble:带两个参数 FunctionWithResultOnly:只需要返回值 FunctionWithParamWithResult:带参数和返回值 FunctionWithDoubleParamWithResult:带两个参数和返回值 例如: FunctionManager.getInstans().addFunction(new FunctionWithDoubleParamWithResult(CommunicationConstants.TEST) { @Override public Integer function(Integer param, Integer integer) { return param + integer; } }); 4. CommunicationConstants.TEST是事件名字,尽量在项目定义一个常量类来规范使用,并且需要保证唯一性,方便维护 5. 调用事件 例如: Integer integer = FunctionManager.getInstans().invokeFunc(CommunicationConstants.TEST, 1, 3, Integer.class); 6. 在设置事件的页面的销毁时移除事件减少内存 例如: FunctionManager.getInstans().removeFunction(CommunicationConstants.TEST); #### 码云特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)