用 Kotlin 简单实现了一个 EventBus
compile 'com.werb.eventbuskotlin:eventbuskotlin:0.2.0'
or
implementation 'com.werb.eventbuskotlin:eventbuskotlin:0.2.0'
EventBus.register(this)
EventBus.unRegister(this)
class XXXXEvent: IEvent
EventBus.post(XXXEvent())
- tag 用于细化区分事件
- mode 方法执行线程
@Subscriber(tag = DEFAULT_TAG, mode = ThreadMode.MAIN)
private fun change2(event: XXXEvent){
textView2.text = "今天星期五"
textView2.setTextColor(resources.getColor(R.color.colorAccent))
println("myActivity - 200")
}