Rxjava 1.1.8
我们的想法是使用订阅来监听处理程序消息,但message.what
属性始终为0。
class RxHandler(looper: Looper) : Handler(looper) {
val messagesObservable = PublishSubject<Message>()
override fun handleMessage(msg: Message?) {
super.handleMessage(msg)
msg?.let { messagesObservable.onNext(it) }
}
}
然后订阅它:
playbackHandler.messagesObservable
.subscribe({
// it.what is always 0
}, { Timber.e(it, "Error on playback handler message handling") })
然后:
playbackHandler.sendEmptyMessage(1)
然后我得到message.what == 0
预期:message.what == 1