Coder Social home page Coder Social logo

liangliang9903 / android-modular Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeremyliao/android-modular

0.0 0.0 0.0 421 KB

一套Android组件化的实施方案和支撑框架:new::tada::tada:

License: Apache License 2.0

Java 83.83% Groovy 16.17%

android-modular's Introduction

android-modular

一套Android组件化的实施方案和支撑框架 image

组件通信框架

  • 组件方法调用框架
    • 编译时组件
    • 插件
    • 运行时框架
  • 组件消息总线框架

组件化构架

  • 壳工程
  • 组件层
    • 组件对外暴露层
      • 接口定义
      • 消息定义
    • 组件实现层
  • 公共模块 image

组件结构

组件对外暴露层

image

消息定义

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
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'

android-modular's People

Contributors

jeremyliao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.