Former Baidu SLG Android Development Engineer, currently residing in ChongQing.
This is my BLOG.
🚀 Awesome EventBus by RxJava.
Home Page: https://lsxiao.github.io/Apollo/
License: Apache License 2.0
Former Baidu SLG Android Development Engineer, currently residing in ChongQing.
This is my BLOG.
api 'com.github.lsxiao.Apollo:core:1.0.2'
kapt "com.github.lsxiao.Apollo:processor:1.0.2"
只有写在app.gradle才能收到事件,写在library.gradle收不到,有解决办法吗
我的一个activity里面有一个viewPager+fragment,activity和viewPager中的fragment都注册了Apollo,但是在某一个fragment中发送两个事件,一个是向activity中发送,另一个是向别的fragment中发送,只会生效其中一个
作者你好,我碰到了一个问题,我在adapter里使用Apollo.emit发送事件,在已经bind的Fragment里面无法接收到相应的事件。而如果在Fragment发送,则可以正常在Fragment接收。
Apollo是不是只能在Activity或Fragment中发送事件才能被正常接收呢,还是说发送事件的类也需要进行bind操作?
Im using Kotlin and I have problem ApolloBinderGeneratorImpl.instance()
does not exist.
What im doing wrong?
//class App: Application() {
override fun onCreate() {
super.onCreate()
Apollo.init(AndroidSchedulers.mainThread(), ApolloBinderGeneratorImpl.instance(), this)
}
my gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
...
//event bus
implementation "com.github.lsxiao.Apollo:core:1.0.0-rc.4"
implementation "com.github.lsxiao.Apollo:ipc:1.0.0-rc.4"
kapt "com.github.lsxiao.Apollo:processor:1.0.0-rc.4"
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation "io.reactivex.rxjava2:rxjava:2.1.1"
implementation "io.reactivex.rxjava2:rxkotlin:2.1.0"
你说SubscriptionBinder 可以在基类里面绑定和解绑定,为啥不直接来个默认的获取SubscriptionBinder的方法呢? 这样我不在基类里面用就很方便啦,
比如: EventBus.getDefault().register(......this);
因为有时候 需要在某些没有基类的地方获取消息
你好,调用Apollo.emit一次 有的@receive的方法会多次接收到消息。
Could not resolve all files for configuration ':app:kapt'.
Could not download kryo-shaded.jar (com.esotericsoftware:kryo-shaded:4.0.0)
> Could not get resource 'https://jcenter.bintray.com/com/esotericsoftware/kryo-shaded/4.0.0/kryo-shaded-4.0.0.jar'.
> Could not GET 'https://jcenter.bintray.com/com/esotericsoftware/kryo-shaded/4.0.0/kryo-shaded-4.0.0.jar'.
> Connect to akamai.bintray.com:443 [akamai.bintray.com/23.42.190.84] failed: Connection timed out: connect
Could not download guava.jar (com.google.guava:guava:23.5-jre)
> Could not get resource 'https://jcenter.bintray.com/com/google/guava/guava/23.5-jre/guava-23.5-jre.jar'.
> Could not GET 'https://jcenter.bintray.com/com/google/guava/guava/23.5-jre/guava-23.5-jre.jar'.
> Connect to akamai.bintray.com:443 [akamai.bintray.com/23.42.190.84] failed: Connection timed out: connect
说是下载不了
我是这么配置的
def apolloVersion = "1.0.1-fix"
apollo = [
//Apollo的核心库
core : "com.github.lsxiao.Apollo:core:$apolloVersion",
processor: "com.github.lsxiao.Apollo:processor:$apolloVersion",
//IPC,如不需要可以不依赖
ipc : "com.github.lsxiao.Apollo:ipc:$apolloVersion"
]
然后在 app的gradle中
implementation apollo.core
kapt apollo.processor
这个仓库也添加了
maven { url "https://jitpack.io" }
compile 'io.reactivex.rxjava2:rxjava:2.1.7'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation "com.github.lsxiao.Apollo:core:1.0.1"
annotationProcessor "com.github.lsxiao.Apollo:processor:1.0.1"
在build.gradle中添加了以上依赖,编译时报了Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
java.lang.NoClassDefFoundError: com/lsxiao/apollo/core/annotations/Receive的错误,请问应如何解决
很赞,有源码分析吗?
文档中提供的混淆规则不够全面,启用 ProGuard
时 ApolloBinderGeneratorImpl
这个类也被混淆了,导致在 Apollo.kt
第 81 行使用反射获取这个类的 instance
方法时出现错误,应用崩溃。
应增加以下规则:
-keep class com.lsxiao.apollo.generate.** { *; }
另外,我发现英文版的文档没有提供混淆规则。
MainActivity里面
@receive(AppConstants.RXBUS_SET_MENSTRUL_DAY_CIRCLE)
public void updateUser(User user) {
mainViewModel.updateUser(user);
}
在ApolloBinderGeneratorImpl里面没有找到绑定MainActivity的代码,
但是其他类可以生成绑定代码
Hi,
I see that you are using "old" version of RxJava
//libs
rxjava2 = "2.0.5"
Is it possible to update to the last version ?
Thanks
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lin.sexy/com.lin.sexy.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'com.lsxiao.apllo.entity.SubscriptionBinder com.lsxiao.apllo.Apollo$SubscriberBinder.bind(java.lang.Object)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2457)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2517)
at android.app.ActivityThread.access$900(ActivityThread.java:168)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5643)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:689)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'com.lsxiao.apllo.entity.SubscriptionBinder com.lsxiao.apllo.Apollo$SubscriberBinder.bind(java.lang.Object)' on a null object reference
at com.lsxiao.apllo.Apollo.uniqueBind(Apollo.java:212)
at com.lsxiao.apllo.Apollo.bind(Apollo.java:185)
at com.lin.sexy.MainActivity.onCreate(MainActivity.java:24)
——————————————————————————————————————
public class MainActivity extends RxAppCompatActivity {
private SubscriptionBinder binder;
TestStore testStore;
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
binder = Apollo.get().bind(this);
Error:(14, 34) 错误: 程序包com.lsxiao.apollo.generate不存在
高优先级的可以中断event,有很多实用场景
Hi,
It seems that recent changes on gradle configuration make Jitpack error : https://jitpack.io/com/github/lsxiao/Apollo/18be65ac08/build.log
org.gradle.jvmargs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
I think it should go into a local.properties (not versioned).
Thanks for your library :)
Regards
Hi. @lsxiao
I'm graphic designer. I wanted to contribute to your project and I've designed a logo for your project. If you like it, you can use it. it's free. I'll send you files and pr.
Best Regard.
Mirza Zulfan
闪退
由于项目中还有较多的部分依赖于rxjava1,目前没有升级的计划。希望能保留一个rxjava1的分支
因为在做模块化开发,所以一些模块是以library的形式引入的,如果在library中使用@receive注解,会在library/build/intermidtates/classes/debug/com/lsxiao/apollo/generate/目录下生成ApolloBinderGeneratorImpl,因为app这边也在它目录下生成了ApolloBinderGeneratorImpl,所以导致Program type already present:ApolloBinderGeneratorImpl的错误。如果在library的build.gradle文件中不声明apollo的compiler,library中的@receive注解就会失效,收不到事件。
用 eventbus 有权重功能,感觉很好,比如多个tag接收同一事件,按照不同权重顺序接收。
还有 MAIN, IO, NEW, COMPUTATION, TRAMPOLINE, IMMEDIATE 这几个分别说明一下啊 ,是不是和eventbus 的一样呢
跟JAVA一样吗 init是写在activity/fragment还是Application里面初始化?
如下配置,无法找到com.lsxiao.apollo.generate.ApolloBinderGeneratorImpl包,哪里出问题了,求教
//Apollo的编译时注解处理器
annotationProcessor "com.github.lsxiao.Apollo:processor:1.0.0-rc.3"
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://www.jitpack.io" }
}
}
toast("修改备注成功")
finish()
Apollo.emit("remark", remark_edit.text.toString())
在emit前就能够finish掉Activity ,但是emit后面写finish 当前的Activity就不会被关掉,求解。
由于家逢大变,本人已于19年5月从百度离职,目前已经未从事Android相关工作,暂无力更新此项目,需要新的维护者加入。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.