- 组件方法调用框架
- 编译时组件
- 插件
- 运行时框架
- 组件消息总线框架
public class ModuleBEvent implements IModularEvent {
final public String content;
public ModuleBEvent(String content) {
this.content = content;
}
}
public interface ModuleBInterface extends IInterface {
void launchModuleBMainPage(Context context);
}
用注解@ModuleService制定实现的接口
@ModuleService(interfaceDefine = ModuleBInterface.class)
public class ModuleBInterfaceImpl implements ModuleBInterface {
@Override
public void launchModuleBMainPage(Context context) {
if (context == null) {
return;
}
context.startActivity(new Intent(context, ModuleBActivity.class));
}
}
userName = ModuleRpcManager.get()
.call(ModuleAInterface.class)
.getUserName();
ModularBus.toObservable(ModuleBEvent.class)
.observe(this, moduleBEvent ->
Toast.makeText(ModuleAActivity.this,
moduleBEvent != null ? moduleBEvent.content : "",
Toast.LENGTH_SHORT).show());
ModularBus.toObservable(ModuleBEvent.class).post(new ModuleBEvent("hello world"));
classpath "com.jeremyliao.modular-tools:plugin:0.0.1"
annotationProcessor "com.jeremyliao.modular-tools:processor:0.0.1"
apply plugin: 'modular-plugin'
implementation "com.jeremyliao.modular-tools:manager:0.0.1"
implementation 'com.jeremyliao:live-event-bus:1.7.2'