EventBus

 

 implementation 'org.greenrobot:eventbus:3.2.0'

  

 

EventBus

package com.qiqi.app.bean;

public class EventMessageWrap {
    public final String message;

    public static EventMessageWrap getInstance(String message) {
        return new EventMessageWrap(message);
    }

    private EventMessageWrap(String message) {
        this.message = message;
    }
}

  

发送fragment:

 EventBus.getDefault().post(EventMessageWrap.getInstance("1"));

  

接收fragment:

 EventBus.getDefault().register(this);

  

 EventBus.getDefault().unregister(this);

  

 

@Subscribe(threadMode = ThreadMode.MAIN)
    public void onGetMessage(EventMessageWrap message) {
        getBannerData();
        getTemplateClassification();
    }

  

 

posted @ 2021-06-26 18:23  a318013800  阅读(61)  评论(0编辑  收藏  举报