JIMU Versions Save

一种简单有效的android组件化方案,支持组件的代码资源隔离、单独调试、集成调试、组件交互、UI跳转、生命周期等完整功能。

v1.3.4

3 years ago

功能新增:

build-gradle

  • 新增manifest合并功能,业务组件中的大部分内容在原始manifest维护即可,runalone时会根据runaloneManifest和原始manifest的主要内容进行合并。
  • 按序初始化业务组件,需使用Maat

修改:

  • gradle插件依赖版本升级到4.0.1
  • Demo迁移到AndroidX

v1.3.3

5 years ago

ADDING: message middle ware.

这个消息中间件拖了很久,一直也没有系统的时间好好处理,可能一些bug之后也未必有时间处理

features:

  • support cross process;
  • use interface to create a manager.(means the manager can orientate to a whole module)
  • use callback (different with event bus)

guide:

step1:

(optional, necessary in cross process ) create a unique sub class of MessageService for a specific process, and notate it with MsgBridgeService. and register it in the manifest

//@MsgBridgeService(workProcessName = "com.luojilab.componentdemo.application")
// empty can represent the default process
@MsgBridgeService(workProcessName = "")
public class MainProcessMsgService extends MessageBridgeService {
    public MainProcessMsgService() {
    }

}

说明:MsgBridgeService#workProcessName的值如果未空代表是默认的进程,其他进程可以使用全进程名或者一个别名,确保全局唯一即可。

step2:

了解小细节 org.github.jimu.msg.EventManager#appendMapper 初始化进程信息。注意,使用JIMU插件会自动生成初始化的代码,不需要任何人工处理,这里仅仅是提一下。

step3:

了解如何为Module创建管理API

public interface AppComponentEventManager {
    @AriseProcess()
    @Event(clz = EventA.class)
    void subscribeEventA(@Consumer ConsumerMeta meta);

    @AriseProcess(pa = ":remote")
    @Event(clz = EventB.class)
    void subscribeEventB(@Consumer ConsumerMeta meta);
}

说明: 建议每个Module将所有的事件订阅统一到一起(或者区分Module内使用的,对外暴露的); 1、接口不可以有继承关系 2、AriseProcess 必要,pa means processAlias,对应step1中workProcessName的值,也即事件发出的进程别名 3、@Event 必要,订阅的事件的类,不支持继承关系,即订阅EventB仅能收到EventB,Foo extends EventB是收不到的。 4、必须void,方法命名随意,形参有且仅有一个,必须使用@Consumer注解

step4:

了解小细节: 如果跨Module订阅,必要的类需要下沉到ComponentService;

step5:

了解初始化 Application#onCreate中 调用:EventManager.init(this);

step6:

了解事件类

非跨进程的:

public class EventA implements EventBean {
}

跨进程的:将需要实现Parcelable

public class EventB implements RemoteEventBean{
    private String msg;

    public EventB(String msg) {
        this.msg = msg;
    }

    protected EventB(Parcel in) {
        msg = in.readString();
    }

    public static final Creator<EventB> CREATOR = new Creator<EventB>() {
        @Override
        public EventB createFromParcel(Parcel in) {
            return new EventB(in);
        }

        @Override
        public EventB[] newArray(int size) {
            return new EventB[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(msg);
    }

    public String getMsg() {
        return msg;
    }
}

step7:

了解小细节:可以通过Router来保持manager 的单例,减少频繁反射、动态代理所带来的损耗

 Router.getInstance().addService(AppComponentEventManager.class.getSimpleName(),
                EventManager.create(AppComponentEventManager.class));

step8:

了解订阅

  EventListener<EventA> eventAEventListener;
    EventListener<EventB> eventBEventListener;

        eventAEventListener = new EventListener<EventA>() {
            @Override
            public void onEvent(EventA event) {
                tvMsg.setText(event.getMsg());
            }
        };

        eventBEventListener = new EventListener<EventB>() {
            @Override
            public void onEvent(EventB event) {
                tvMsg.setText(event.getMsg());
            }
        };

//        EventManager.getInstance().subscribe(EventA.class, eventAEventListener);

        AppComponentEventManager manager = (AppComponentEventManager) Router.getInstance()
                .getService(AppComponentEventManager.class.getSimpleName());

        manager.subscribeEventA(ConsumerMeta.<EventA>newBuilder()
                .consumeOn(ConsumeOn.Main)
                .eventListener(eventAEventListener)
                .build());

        manager.subscribeEventB(ConsumerMeta.<EventB>newBuilder()
                .consumeOn(ConsumeOn.Main)
//                .process("") // 一般来说,都不需要特地写进程了,我们约定""就代表默认进程
                .eventListener(eventBEventListener)
                .build());

step9

了解解注册

 EventManager.getInstance().unsubscribe(eventBEventListener);
        EventManager.getInstance().unsubscribe(eventAEventListener);
      

step10

了解发布

 EventManager.getInstance().postEvent(new EventB("event b from Msg3Activity"));

其实了解实现思路之后用EventBus等成熟框架重新封装更加合适,不过eventbus本身的设计和API式管理不太协调。

另外一些细节不再赘述,因个人工作和生活原因可能不能对这个中间件提供足够的技术支持,这也是我没有将它独立出来成为一个lib的原因,所以希望对该功能比较感兴趣的朋友们多阅读源码。

v1.3.2-alpha

5 years ago

Bundle Content:

In this bundle, following are contained:

  • com.github.jimu:componentlib:1.3.2-alpha (new)
  • com.github.jimu:build-gradle:1.3.2 (new)
  • com.github.jimu:router-annotation:1.0.1 (no change)
  • com.github.jimu:router-annotation-compiler:1.0.1 (no change)

Change Logs:

componentLib:

  • add Decorator to decorate the Intent for UiRouter
  • add core of Message middle ware not fully completed, one extension will be provided to maintain the event subscribe/describe
  • add notation: com.luojilab.component.componentlib.applicationlike.RegisterCompManual #23
  • #25

build-gradle:

  • add support for "asR“ and so on, see #28
  • #23 make the register for sub-component more flexable

v1.3.1

6 years ago

in this version release bundle, following contains

  • componentlib:1.3.1
  • router-annotation:1.0.1
  • router-annotation-compiler:1.0.1;

changeLog:

router-annotation

just first release in JIMU (com.github.jimu as artifact Id)

router-annotation-compiler

  • compile router-annoation 1.0.1 in the dependancy;
  • use new api of componentLib in generated class;

componentlib

  • compile router-annoation 1.0.1 in the dependancy;
  • upgrade the api of jsonService.Factory AutowiredService.Factory use singleton to make cache useful
  • upgrade the internal logic of UIRouter. now it may be easier to debug.
  • support inspecting field when missing required params in navigation

Integration:

compile 'com.github.jimu:componentlib:1.3.1'
annotationProcessor 'com.github.jimu:router-anno-compiler:1.0.1'

attention: router-annotation has been contained in componentlib use kapt instead of annotationProcessor in kotlin-module. all in jcenter!

if the request to include componentlib is still pending. you can use

maven {
            url 'https://dl.bintray.com/leobert-lan-oss/maven/'
        }

as a cheat😂.


enjoy it!