EventBusDemo

时间:2018-06-07 11:22:06
【文件属性】:
文件名称:EventBusDemo
文件大小:629KB
文件格式:RAR
更新时间:2018-06-07 11:22:06
android enentbus public void onEvent(Event event){ android.util.Log.e("zhai", "看父类event也接收了"+event.getTag()); } /** * 使用onEvent来接收事件,那么接收事件和分发事件在一个线程中执行 * @param event */ public void onEvent(PostEvent event) { Log.d("zhai", "OnEvent-->"+Thread.currentThread().getId()); } /** * 使用onEventMainThread来接收事件,那么不论分发事件在哪个线程运行,接收事件永远在UI线程执行, * 这对于android应用是非常有意义的 * @param event */ public void onEventMainThread(MainEvent event) { Log.d("zhai", "onEventMainThread-->"+Thread.currentThread().getId()); } /** * 使用onEventBackgroundThread来接收事件,如果分发事件在子线程运行,那么接收事件直接在同样线程 * 运行,如果分发事件在UI线程,那么会启动一个子线程运行接收事件 * @param event */ public void onEventBackgroundThread(BackEvent event) { if (event.getTag() == Event.TAG_BACK){ Log.d("zhai", "onEventBackgroundThread-->"+Thread.currentThread().getId()); } else { Log.d("zhai", "onEventBackgroundThread 接受了无效的信息"); } } /** * 使用onEventAsync接收事件,无论分发事件在(UI或者子线程)哪个线程执行,接收都会在另外一个子线程执行 * @param event */ public void onEventAsync(AsyncEvent event) { if(event.getTag() == Event.TAG_ASYNC){ Log.d("zhai", "onEventAsync-->"+Thread.currentThread().getId()); }else { Log.d("zhai", "onEventAsync 接受了无效的信息"); } } public void TestEvent(PostEvent post){ Log.d("zhai", "注册方法也能接受到信息"); }
【文件预览】:
EventBusDemo
----.project(848B)
----project.properties(563B)
----src()
--------com()
----AndroidManifest.xml(1KB)
----res()
--------drawable-ldpi()
--------drawable-hdpi()
--------values-v11()
--------menu()
--------drawable-mdpi()
--------layout()
--------values-sw600dp()
--------drawable-xxhdpi()
--------drawable-xhdpi()
--------values()
--------values-sw720dp-land()
--------values-v14()
----.settings()
--------org.eclipse.core.resources.prefs(57B)
----assets()
----gen()
--------com()
----libs()
--------eventbus.jar(22KB)
--------android-support-v4.jar(543KB)
--------Jatec2_fat.jar(28KB)
----.classpath(475B)
----proguard-project.txt(781B)
----ic_launcher-web.png(50KB)
----bin()
--------classes()
--------AndroidManifest.xml(1KB)
--------jarlist.cache(119B)
--------res()

网友评论

相关文章