LiveEventBus icon indicating copy to clipboard operation
LiveEventBus copied to clipboard

在同一个Acticity中接收俩个消息 Key无效

Open e9ab98e991ab opened this issue 7 years ago • 4 comments

无论我使用postValue 或者是 setValue 在一个activity中向另一个activity中发送消息 Key值不同 ,但是在第二个activity 中的fragment俩个 observeSticky 方法均执行。

e9ab98e991ab avatar Aug 27 '18 09:08 e9ab98e991ab

请问有什么特殊的复现场景吗,我试了一下没有复现

JeremyLiao avatar Aug 28 '18 07:08 JeremyLiao

fragment中回收到两个次事件 01-15 16:44:58.135 28220-28220/? I/[LiveEventBus]: post: true with key: isFinishRefresh 01-15 16:44:58.135 28220-28220/? I/[LiveEventBus]: message received: true 01-15 16:44:58.135 28220-28220/? I/[LiveEventBus]: message received: true

jsjxsy avatar Jan 15 '20 08:01 jsjxsy

fragment中回收到两个次事件 01-15 16:44:58.135 28220-28220/? I/[LiveEventBus]: post: true with key: isFinishRefresh 01-15 16:44:58.135 28220-28220/? I/[LiveEventBus]: message received: true 01-15 16:44:58.135 28220-28220/? I/[LiveEventBus]: message received: true

是不是注册了两个接收者,贴下代码呢

JeremyLiao avatar Jan 16 '20 01:01 JeremyLiao

//注册liveDataBus订阅
LiveEventBus.get(DOWNLOADMESSAGE, String::class.java) .observe(this, Observer { var downInfo = ArrayList<DownloadApkInfo>()

            Log.e("pengxiognwei",it+"==")
        })

    //注册liveDataBus订阅
    LiveEventBus.get(ISMANAGEREDITSTATUS, Boolean::class.java)
        .observe(this, Observer {
            isManagerEditStatus = it
            downloadBinding.xyDownloadTextEdit.text = if (isManagerEditStatus) {
                "取消"
            } else {
                "编辑"
            }
        })

以上是同一个activity中注册的2个不同消息key,接收不到消息,麻烦看下,日志如下

post: http://apk1.ggxx.net/newadminpk/channles_sdk/SDKTool/output/606/1.0.1/chuangyou/wcyx_01_1.0.1_chuangyou01_1.0.0.apk with key: DOWNLOADMESSAGE 2021-04-23 13:11:40.737 13531-13531/com.hnrc.gamebox.hapimarket I/[LiveEventBus]: observe observer: com.jeremyliao.liveeventbus.core.LiveEventBusCore$ObserverWrapper@e3cd55d(com.hnrc.gamebox.hapimarket.down.DownLoadApkActivity$onCreate$1@32f05fe) on owner: com.hnrc.gamebox.hapimarket.down.DownLoadApkActivity@2ff4996 with key: DOWNLOADMESSAGE 2021-04-23 13:11:40.738 13531-13531/com.hnrc.gamebox.hapimarket I/[LiveEventBus]: observe observer: com.jeremyliao.liveeventbus.core.LiveEventBusCore$ObserverWrapper@2038ba3(com.hnrc.gamebox.hapimarket.down.DownLoadApkActivity$onCreate$3@3204ea0) on owner: com.hnrc.gamebox.hapimarket.down.DownLoadApkActivity@2ff4996 with key: ISMANAGEREDITSTATUS

willBars avatar Apr 23 '21 05:04 willBars