- 首先今天遇到的坑 接收者 必须是被打开的状态 也可以说没被销毁状态
2.配置
buildscript {
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
compile 'org.greenrobot:eventbus:3.0.0'
apt 'org.greenrobot:eventbus-annotation-processor:3.0.1'
}
apt {
arguments {
eventBusIndex "com.example.myapp.MyEventBusIndex"
}
}
3.混淆
-keepattributes *Annotation*
-keepclassmembers class ** {
@org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
# Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
<init>(java.lang.Throwable);
}
4.用法
EventBus.getDefault().register(this);
EventBus.getDefault().unregister(this);
5.另一篇文章
事件总线的思路源于(https://github.com/greenrobot/EventBus)
不过代码和实现方式完全不同于EventBus.(https://github.com/LuckyJayce/EventBus)