Android--Otto事件总线 -- 组件之间通讯框架使用 --模式解析
前言:Otto事件总线 -- 组件之间通讯框架
对于之前的情况activity之间或者fragment之间等跳转传值一般都是用bundle、intent等,从activityA --- activityB用startActivity,用startActivityForResult()可以接受后者回到前者的参数并且可做一些更新UI等操作。这样一来就要判断从A中哪一个按钮跳转到了B,就要设置唯一标识定义什么FRIST=1,FFFFF=2等。Otto事件总线解决了这个问题,只要在订阅事件,接收方接受订阅,传值类型为唯一标示。这样子只要在触发了post后,接受方就会执行指定方法,就算不返回到A界面也是可以执行的。
使用Otto事件总线框架的原因
- 一般情况下,在Android中的Activity与Activity之间值的传递,我们通过Intent的方式;
- Activity与Fragment之间我们通过setArguments,值回调我们是在Fragment中的onAttach()接口方式实现;
- Activity与service之间,我们通常会使用binder机制,但是binder机制实际上使用的也是接口回调的方式;
- 在一些比较复杂的情况,比如Activity嵌套多个Fragment页面的时候,如果一个页面的值发生了改变,其他的页面也要跟着发生数据的更新操作,这样我们会频繁的使用接口回调的方式,这种方式的耦合性太高。
Otto事件的模式
对于一个如此方便的框架,Java模式的加入是必不可少的,无论是Rxjava(观察者模式扩展)还是EventBus都有观察者模式,所以中间讲解该模式。
一、简单使用
@Subscribe:这个在调用了register后有效,表示订阅了一个事件,并且方法的用 public 修饰的.方法名可以随意取,重点是参数,它是根据你的参数进行判断
@Produce注解告诉Bus该函数是一个事件产生者,产生的事件类型为该函数的返回值。
1-1:添加依赖
dependencies {
compile 'com.squareup:otto:1.3.8'
}
或者
//otto事件总线
compile 'com.squareup:otto:+'
1-2:订阅和取消订阅
bus.register(this);
bus.unregister(this);
发布:
bus.post(new MessageEvent());
注解
@Subscribe:这个在调用了register后有效,表示订阅了一个事件,并且方法的用 public 修饰的.方法名可以随意取,重点是参数,它是根据你的参数进行判断 @Produce注解告诉Bus该函数是一个事件产生者,产生的事件类型为该函数的返回值。 最后,proguard 需要做一些额外处理,防止混淆:
-keepattributes *Annotation*
-keepclassmembers class ** {
@com.squareup.otto.Subscribe public *;
@com.squareup.otto.Produce public *;
}
1-3:otto推荐使用单例模式,保证只有一个实例
public class BusProvider extends Bus { /**
* 通过单例模式返回唯一的bus对象,而且重写父类的post方法,通过handler实现任意线程可以调用
*/
private Handler mHandler = new Handler(Looper.getMainLooper());
private static Bus bus = new BusProvider(); private BusProvider(){ } public static Bus getInstance(){ return bus;
} @Override
public void post(final Object event) {
if (Looper.myLooper() == Looper.getMainLooper()) {
super.post(event);
}else {
mHandler.post(new Runnable() {
@Override
public void run() {
BusProvider.super.post(event);
}
});
}
}
}
1-4:调用 A-->B
@Subscribe
activityA:
/**
* Created by 刘志通 on 2018/7/4.
*/ public class OttoTestOne extends AppCompatActivity {
private Bus bus;
private Button button,button2;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ottotwo_layout);
//订阅
bus = BusProvider.getInstance();
bus.register(this);
button = findViewById(R.id.id_two);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(OttoTestOne.this,OttoTestTwo.class);
startActivity(intent);
}
}); }
//注解接收String类型
@Subscribe
public void setText(String textstring) {
button.setText(textstring);
Log.e("检测1",textstring+"");
}
//接收bean类型
@Subscribe
public void setText2(EditBean textstring) {
button2.setText(textstring.getEdit1()+""+textstring.getEdit2());
Log.e("检测2", textstring.getEdit1()+""+textstring.getEdit2());
} /**
* 取消订阅
* */
@Override
protected void onDestroy() {
BusProvider.getInstance().unregister(this);
super.onDestroy();
}
}
activityB
/**
* Created by 刘志通 on 2018/7/4.
*/ public class OttoTestTwo extends AppCompatActivity { private Bus bus; @Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//获取实例
bus = BusProvider.getInstance();
//注册
bus.register(this);
setContentView(R.layout.ottoone_layout);
Button button=findViewById(R.id.id_btn); button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/*发送,这里发送的是bean,也可以直接发送String类型的数据,接收则是A中String类型的接收。*/
EditBean editBean=new EditBean();
editBean.setEdit1("ni");
editBean.setEdit2(" hao");
editBean.setTotal(" ma");
bus.post(editBean);
}
});
}
}
@Produce
只要有activity或者fragment跳转到该页面后,事件就会自动产生,然后在订阅处(谁订阅谁改变)更新一些数据。
//获取实例
bus = BusProvider.getInstance();
//注册
bus.register(this);
setContentView(R.layout.ottothird_layout);
}
@Produce
public EditBean providerEvent(){
EditBean eventData = new EditBean();
eventData.setEdit1("hello world");
return eventData;
} @Override
protected void onDestroy() {
super.onDestroy();
bus.unregister(this);
}
注:A->B中 @Produce模式则是在A中发起事件,也就是所谓的事件产生者,当从A跳转到B后,如果B中有对EditBean有操作的话,就直接触及到A的@Produce方法,并更新一些数据,这和Post比起来,有点简单,因为你都不用再做任何操作,前一个界面就已经更新了,但Post可以控制何时发起事件,点击按钮后或者网络请求成功后直接bus.post(" ... ");
二、观察者模式
前言
观察者模式(有时又被称为模型-视图(View)模式、源-收听者(Listener)模式或从属者模式)是软件设计模式的一种。在此种模式中,一个目标物件管理所有相依于它的观察者物件,并且在它本身的状态改变时主动发出通知。这通常透过呼叫各观察者所提供的方法来实现。此种模式通常被用来实现事件处理系统。
需要注意:
实现观察者模式的时候要注意,观察者和被观察对象之间的互动关系不能体现成类之间的直接调用,否则就将使观察者和被观察对象之间紧密的耦合起来,从根本上违反面向对象的设计的原则。无论是观察者“观察”观察对象,还是被观察者将自己的改变“通知”观察者,都不应该直接调用。
观察者
(Observer)将自己注册到被观察对象(Subject)中,被观察对象将观察者存放在一个容器(Container)里。
被观察
被观察对象发生了某种变化,从容器中得到所有注册过的观察者,将变化通知观察者。
撤销观察
观察者告诉被观察者要撤销观察,被观察者从容器中将观察者去除。
观察者将自己注册到被观察者的容器中时,被观察者不应该过问观察者的具体类型,而是应该使用观察者的接口。这样的优点是:假定程序中还有别的观察者,那么只要这个观察者也是相同的接口实现即可。一个被观察者可以对应多个观察者,当被观察者发生变化的时候,他可以将消息一一通知给所有的观察者。基于接口,而不是具体的实现——这一点为程序提供了更大的灵活性。
aaarticlea/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAr4AAAHCCAYAAAAJj8pSAAAgAElEQVR4nO3dPVYi3RYG4M1d31CkA5cjwBFIJ0amZhhC0plhZ51AKJmpkYkwAhmBy6BhLtyqAqTE8reVH8/zfIt7G6g/AeF1s8+p2jQTAADwzf1v0wcAAADrIPgCAJAEwRcAgCQIvgAAJEHwBQAgCYIvAABJEHwBSia9w6gd9mJScd/wrBaHvap7nr+/2N7Z8IU9DuOsVovauy5n8dIWAagm+AI8GMafTkT3sh17WfTtHT4OnM1+xKhTfxxCXwm1xfZ+Hb2y30Z0x9PIp1XPL4NWflM3xtPlbQ+XcTdbGoCPEHwB5oZnzbjrXkZ7L7+2F+3bx6EzD6SN7vhxEL14PtTm2+vHKDr1qqrtYVQWj4dnRcDOEnbUV9Z5qdoMwOsEX4BcHjhjELd56p304vC5YFq56mpFOFu3lwfYVgyqqrbTQbSeOYZavpGVau+4m9d4W3E+S+QAfJDgC5Dp/c4CZ785q67WO3EwuI32+OyVVodZOD66yAPqOPJ8OqsIX0Zc3UV3fBF5PbgIxi+2RGTGWdhuxiwon99HvejjnbVb1K9OsiA82xYAH/ffpg8AYBvkbQ3tImjW4/58GrMOhossxF68cQvjuB9lwXhUj7Mf2fq3t7ObJ7343c97eF+JrfV2ZIcwc3QcrWhGs9YvrrYGec8xAP9KxRdgbtI7LYXe9657HXdFxbcb0Vy2SQyL0W3nEacvt07c/zksVZKv47jU6nB8vaw6n9187GcDQPAFmJn04rQzin6z3MbwylRjD9OeDePP1X6cHOT//hm/sux7dTOZVXvvunHZPor25Ulc1cvTkB3Ej1IZd//XbWkQXT+ape3PWilml4ufa31UAL4VwRcgM7m5ilHkbQWLkHk7n93h8VRjD5fBcnjapPc77k5+xo/59b32bdy2x3FWv4qTy3mbwl47zvNAm/f6Tv7G3QvH8hB0i17f2rPzCgPwPnp8AWIWVqftj607vj+I84ss3p6VbhxeF1OZZck1Oo+W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ATwVd4AQDgX2l1AAAgCYIvAABJEHwBAEiC4AsAQBIEXwAAkiD4AgCQBMEXAIAkCL4AACRB8AUAIAmCLwAASRB8AQBIguALAEASBF8AAJIg+AIAkATBFwCAJAi+AAAkQfAFACAJgi8AAEkQfAEASILgCwBAEgRfAACSIPgCAJAEwRcAgCQIvgAAJEHwBQAgCYIvAABJEHwBAEiC4AsAQBIEXwAAkiD4AgCQBMEXAIAkCL4AACRB8AUAIAmCLwAASfhvHTup1Wrr2A0AADxLxRcAgCQIvgAAJEHwBQAgCYIvAABJ+PTBbdPp9LM3CQAA/0zFFwCAJAi+AAAkQfAFACAJgi8AAEkQfAEASILgCwBAEgRfAACSIPgCAJAEwRcAgCQIvgAAJEHwBQAgCYIvAABJEHwBAEiC4AsAQBIEXwAAkiD4AgCQBMEXAIAkCL4AACRB8AUAIAmCLwAASfg/JOjEQR13SmoAAAAASUVORK5CYII=" alt="image" data-src="https%3A%2F%2Fnote.youdao.com%2Fyws%2Fpublic%2Fresource%2Ffd36036c9f62a9f98e514c2a9937b2ed%2Fxmlnote%2F404377B1E1F44ED193DF60215A195310%2F2781" data-processed="https%3A%2F%2Fnote.youdao.com%2Fyws%2Fpublic%2Fresource%2Ffd36036c9f62a9f98e514c2a9937b2ed%2Fxmlnote%2F404377B1E1F44ED193DF60215A195310%2F2781" />
举例子:
这里创建一个抽象观察者(Observer)和一个被观察者(Subject),然后继承抽象观察者,观察者们通过观察被观察者(Subject)来改变自己。
创建类:
- 抽象观察者(Observer)
- 被观察者(Subject)
2-1:被观察者Subject.java
public class Subject {
private List<Observer> observers
= new ArrayList<Observer>();
private Observer observer;
private int state;
//变更情况
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
//绑定
public void binding(Observer observer) {
observers.add(observer);
}
/**
* unbinding(注销观察者,有时候在未获取到实例使用)
**/
public void unbinding(Observer cls) {
if (cls == null) throw new NullPointerException();
observers.remove(cls); }
//通知
public void notifyAllObservers() {
for (Observer observer : observers) {
observer.update();
}
}
}
这里需要注意的是如果是常规集合是不能直接用remove的,要如下转换再行删除。
Iterator<Observer> iterator = observers.iterator();
2-2:观察者(Observer)
/**
* 观察者
* */
public abstract class Observer {
protected Subject subject;
public abstract void update();
}
2-3:继承Observer
需要注意的是,我这里创建了3个如下类,只粘贴出一个,分别是FirstObserver,SecondObserver,ThirdObserver。
public class FirstObserver extends Observer {
public FirstObserver(Subject subject) {
this.subject = subject;
subject.binding(this);//绑定
}
@Override
public void update() {
//用来更新数据
System.out.println("我是第一个观察者:"+subject.getState());
}
}
2-4:测试
在主方法main中 这里是在每个子类的构造方法中加入了绑定,所以,只要创建对象就已经绑定了,无序再次绑定,当然也是可以解绑的。
//加载被观察者
Subject subject = new Subject();
//加载观察者
FirstObserver firstObserver = new FirstObserver(subject);
SecondObserver secondObserver = new SecondObserver(subject);
ThirdObserver thirdObserver = new ThirdObserver(subject);
subject.setState(2);
subject.notifyAllObservers();
aaarticlea/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAZwAAADCCAYAAAB9snQKAAAgAElEQVR4nO3dfXAU6X0n8N9IAwu7O0i1Xq2ENErOeSlmhYhISoOoZL3rRcNxVQepgF+SXZSkLqKSqlQSi2KvSsTnqtzlEukPk8VxcvaVpVzVWeTFybJVXi5nzIBfLpfAji4GIxFhx7ux9cIMWm8kDQiEXvqe5+npnlarX56e6ekZRt8PRWmme7r76bfn97z0S6hz336FHNTvfZnmrn+Nfvrnf8X2N9/68v/Uf2dl58Hfpt9+iejrf/LH9NV0SAxTmhJ08rdepPf++lM0ciNEitJEh/p+kz783t/Q7577tmG6H9KXPnmOvrXzIB1qvERfNfz2ua9/ir54vYN++Q8+SpSbD7f3+KtEI2wa2qn/ThunL/sXn6P36AN096/UNCnKT3majzEN+rCOV2ngYx/Q19N5njzdL9Hddb+1/n7xjrqOz37jv9HZS+n8sj58lz579hLdCeXXzWxHfT01tbRSenqSFubmNnx3sm37dsfxAABehINYyJ1Ln6XTN3mA+X16OaRl2HdZxvwpPQB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KpMKPFHF5XlR8tUG64VA1ZXVmnL1i3i0TYryyu0dvdfSPl/b0jNDI+2AQAAO+Ha2hoKPbFFPMqG499rampYLWeFVt//ASljXylzEgEAoBqE75//w3KnAQAANgG8gA0AAAKBgAMAAIFAwAEAgEAg4AAAQCAQcAAAIBAIOAAAEAgEHAAACAQCDgAABAIBBwAAAoGAAwAAgUDAAQCAQCDgAABAIBBwAAAgEAg4AAAQCAQcAAAIBAIOAAAEAgEHAAACgYADAACBQMABAIBAIOAAAEAgEHAAACAQCDgAABAIBBwAAAgEAg4AAAQCAQcAAAKBgAMAAIFAwAEAgEAg4AAAQCAQcAAAIBAIOAAAEAgEHAAACAQCDgAABAIBBwAAAoGAAwAAgUDAAQCAQCDgAABAIP4/8zW5DViQqaEAAAAASUVORK5CYII=" alt="image" data-src="https%3A%2F%2Fnote.youdao.com%2Fyws%2Fpublic%2Fresource%2Ffd36036c9f62a9f98e514c2a9937b2ed%2Fxmlnote%2F4CD8B50942EB4FFBBB359374A7BBD159%2F2782" data-processed="https%3A%2F%2Fnote.youdao.com%2Fyws%2Fpublic%2Fresource%2Ffd36036c9f62a9f98e514c2a9937b2ed%2Fxmlnote%2F4CD8B50942EB4FFBBB359374A7BBD159%2F2782" />
解绑
subject.unbinding(secondObserver);
subject.setState(3);
subject.notifyAllObservers();
aaarticlea/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAgIAAACHCAYAAABkpzGOAAAgAElEQVR4nO3dfXAb530n8C9A2pEj82WSUKRIsNO0mQqiqJI3IUh1mtiyCFm+qXRzki07Ndne3FDTzvguMTXKH1KTzKRNXPKPaCw7aSZ/kO1MQ/Uau5bnat7UsiDVbvKHZTARWZEU5Gmcm5KgSNFxSUKSTUkk+jy7WHABLPYF7xK+Hw8tYBf77LMv2Of3vOzC1dG5KwqhZbsX01dCeGjTJnzK+3uwa2n8n1OmRaO/iz964Sng1W9hZMKVOK/tWQwcBl75xmlcwlbs638OW95O/VwpikYbDPMbbfDj6P/egrfFNo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ublic%2Fresource%2Ffd36036c9f62a9f98e514c2a9937b2ed%2Fxmlnote%2F93B1BAEAE26B4C5BBC7AD998C6097A2F%2F2780" data-processed="https%3A%2F%2Fnote.youdao.com%2Fyws%2Fpublic%2Fresource%2Ffd36036c9f62a9f98e514c2a9937b2ed%2Fxmlnote%2F93B1BAEAE26B4C5BBC7AD998C6097A2F%2F2780" />
Android--Otto事件总线 -- 组件之间通讯框架使用 --模式解析的更多相关文章
- Otto事件总线框架的使用
Otto是一个在Android中的事件总线框架,它是square的一个开源框架,具体介绍点击这里,项目下载点击这里 为什么要使用Otto事件总线: 通常来说在Android中: 1.Activity与 ...
- Android开发事件总线之EventBus运用和框架原理深入理解
[Android]事件总线之EventBus的使用背景 在我们的android项目开发过程中,经常会有各个组件如activity,fragment和service之间,各个线程之间的通信需求:项目中用 ...
- Angular 发布订阅模式实现不同组件之间通讯
在我们项目中要实现不同组件之间通讯,Angular的@Input和@Output只能实现有父子组件的限制,如果是复杂跨组件实现不同组件可以通过共享变量的方式实现,比如这个博客的思路:https://w ...
- 【Android】事件总线(解耦组件) EventBus 详解
当Android项目越来越庞大的时候,应用的各个部件之间的通信变得越来越复杂,例如:当某一条件发生时,应用中有几个部件对这个消息感兴趣,那么我们通常采用的就是观察者模式,使用观察者模式有一个弊病就是部 ...
- android开源项目之OTTO事件总线(一)
Otto是由Square发布的一个着重于Android支持的基于Guava的强大的事件总线,在对应用程序不同部分进行解耦之后,仍然允许它们进行有效的沟通. 开源项目地址:https://github. ...
- android开源项目之OTTO事件总线(二)官方demo解说
官方demo见 https://github.com/square/otto 注意自己该编译版本为2.3以上,默认的1.6不支持match_parent属性,导致布局文件出错. 另外需要手动添加an ...
- Angular组件之间通讯
组件之间会有下列3种关系: 1. 父子关系 2. 兄弟关系 3. 没有直接关系 通常采用下列方式处理(某些方式是框架特有)组件间的通讯,如下: 1父子组件之间的交互(@Input/@Output/模板 ...
- vue.js组件之间通讯的数据双向绑定----父亲把数据传递给儿子,儿子更改数据后,重新发送给父亲,父亲数据更改后,属性会重新发送个儿子,儿子刷新新数据
vue组件是相互独立的,如果要交互通讯,这时候,就需要组件之间数据互通了 往常我们讲的都是数据传递,子传父,父传子,都没有说子和父,父与子之间的数据互通 父亲传递给儿子数据,儿子触发一个父亲方法,将最 ...
- angular2 组件之间通讯-使用服务通讯模式 2016.10.27 基于正式版ng2
工作中用到ng2的组件通讯 奈何官方文档言简意赅 没说明白 自己搞明白后 整理后分享下 rxjs 不懂的看这篇文章 讲很详细 http://www.open-open.com/lib/view/ope ...
随机推荐
- Angular--TypeScript finalize 方法
self._entityService .getAll() .pipe( finalize(() => { if (self.sheet && self.sheet.length ...
- pymysql 各种坑总结
pymysql各种坑只针对自己的项目1.关于关闭连接,报错为:pymysql.err.InterfaceError: (0, '') 这个错误原因:对已经关闭的链接再次进行操作,参考MySQL.err ...
- wordpress 后台页面无法显示绑定的台湾语言
问题:当前切换到的语言是English,然后在页面的列表中,分别显示的语言有中文和香港,没有出现台湾的图标,如上图所示 原因:在polylang插件的设置里面,可以看到台湾语言的 Language c ...
- 聊聊Python ctypes 模块(转载)
https://zhuanlan.zhihu.com/p/20152309?columnSlug=python-dev 作者:Jerry Jho链接:https://zhuanlan.zhihu.co ...
- CSS3 pointer-events:none应用举例及扩展
一.pointer-events:none是? pointer-events是CSS3中又一冉冉的属性,其支持的值牛毛般多,不过大多都与SVG相关,我们可以不用理会.当下,对于偶们来讲,与SVG划开界 ...
- FocusBI: 总线矩阵(原创)
关注微信公众号:FocusBI 查看更多文章:加QQ群:808774277 获取学习资料和一起探讨问题. <商业智能教程>pdf下载地址 链接:https://pan.baidu.com/ ...
- 判断字符串中是否包含Emoji表情代码
判断字符串中是否包含Emoji表情代码: + (BOOL)stringContainsEmoji:(NSString *)string { __block BOOL returnValue = NO; ...
- java--多线程之后台线程
public class ThreadDaemon { /** * @param args * 后台线程在主进程结束后,也会退出 */ public static void main(String[] ...
- https Java SSLException protocol_version的问题解决方法
我们的业务代码里有需要用爬虫爬取商品的图片地址,然后在转到我们的服务器里的过程,中间当然少不了下载图片的过程,最近目标网站有些改变,就是之前http前缀的图片地址部分改成了https,然后就造成了一个 ...
- C#之RabbitMQ系列(一)
RabbitMQ–环境搭建 MQ MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法.应用程序通过读写出入队列的消息(针对应用程序的数据)来通信,而无需专用连接 ...