├── core ├── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── lsxiao │ │ │ └── apollo │ │ │ └── core │ │ │ ├── annotations │ │ │ ├── Receive.kt │ │ │ ├── Backpressure.kt │ │ │ ├── Take.kt │ │ │ ├── Sticky.kt │ │ │ ├── ObserveOn.kt │ │ │ └── SubscribeOn.kt │ │ │ ├── serialize │ │ │ ├── Serializable.kt │ │ │ └── KryoSerializer.kt │ │ │ ├── contract │ │ │ ├── ApolloBinder.kt │ │ │ └── ApolloBinderGenerator.kt │ │ │ ├── ProcessUtil.kt │ │ │ ├── entity │ │ │ ├── ApolloBinderImpl.kt │ │ │ ├── SchedulerProvider.kt │ │ │ └── Event.java │ │ │ └── Apollo.kt │ └── test │ │ └── java │ │ └── com │ │ └── lsxiao │ │ └── apollo │ │ └── core │ │ └── KryoSerializeTest.java └── build.gradle ├── demo ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── styles.xml │ │ │ └── strings.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ └── layout │ │ │ ├── dialog_subscriber.xml │ │ │ ├── activity_main.xml │ │ │ ├── fragment_subscriber.xml │ │ │ └── fragment_producer.xml │ │ ├── java │ │ └── com │ │ │ └── lsxiao │ │ │ └── apollo │ │ │ └── demo │ │ │ ├── App.java │ │ │ ├── constant │ │ │ └── Event.java │ │ │ ├── model │ │ │ └── User.java │ │ │ ├── base │ │ │ ├── BaseActivity.java │ │ │ ├── BaseFragment.java │ │ │ └── BaseDialogFragment.java │ │ │ ├── TestService.java │ │ │ ├── fragment │ │ │ ├── SubscriberDialogFragment.java │ │ │ ├── SubscriberFragment.java │ │ │ └── ProducerFragment.java │ │ │ └── TestActivity.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── ipc ├── .gitignore ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── lsxiao │ │ └── apollo │ │ └── ipc │ │ └── ApolloProcessEventReceiver.java ├── build.gradle └── proguard-rules.pro ├── processor ├── .gitignore ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── lsxiao │ │ │ └── apllo │ │ │ └── processor │ │ │ ├── Util.kt │ │ │ ├── step │ │ │ ├── TakeStep.kt │ │ │ ├── StickyStep.kt │ │ │ ├── ObserveStep.kt │ │ │ ├── ReceiveStep.kt │ │ │ ├── SubscribeStep.kt │ │ │ └── BackpressureStep.kt │ │ │ ├── ApolloDescriptor.kt │ │ │ ├── ApolloProcessor.java │ │ │ └── CodeGenerator.kt │ └── test │ │ └── java │ │ └── ProcessUtilTest.kt └── build.gradle ├── unittest ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── lsxiao │ │ │ │ └── apollo │ │ │ │ └── unittest │ │ │ │ └── MainActivity.kt │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── com │ │ └── lsxiao │ │ └── apollo │ │ └── unittest │ │ ├── BasicTest.java │ │ └── BusTest.java ├── proguard-rules.pro └── build.gradle ├── _config.yml ├── demo.gif ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── config └── dependencies.gradle ├── gradlew.bat ├── gradlew ├── README-EN.md ├── README.md └── LICENSE /core/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /ipc/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /processor/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /unittest/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/demo.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':processor', ':demo', ':core', ':ipc', ':unittest' 2 | -------------------------------------------------------------------------------- /ipc/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /unittest/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | unittest 3 | 4 | -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/demo/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/demo/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/demo/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /unittest/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/unittest/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /unittest/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/unittest/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /unittest/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/unittest/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /unittest/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/unittest/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /unittest/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/unittest/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /unittest/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/unittest/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /unittest/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/unittest/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /unittest/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/unittest/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /unittest/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/unittest/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /unittest/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sloaix/Apollo/HEAD/unittest/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /demo/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /unittest/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /processor/src/main/java/com/lsxiao/apllo/processor/Util.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apllo.processor 2 | 3 | object Util { 4 | fun split(list: List, separator: String): String { 5 | return list.mapTo(ArrayList()) { "\"$it\"" }.joinToString(separator) 6 | } 7 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 11 21:10:58 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 7 | -------------------------------------------------------------------------------- /unittest/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /unittest/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /core/src/main/java/com/lsxiao/apollo/core/annotations/Receive.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.core.annotations 2 | 3 | /** 4 | * author lsxiao 5 | * date 2016-08-07 18:14 6 | */ 7 | @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) 8 | @kotlin.annotation.Retention 9 | annotation class Receive(vararg val value: String) 10 | -------------------------------------------------------------------------------- /ipc/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | group = 'com.github.lsxiao' 5 | android { 6 | def config = parent.ext 7 | 8 | compileSdkVersion config.compileSdkVersion 9 | buildToolsVersion config.buildToolsVersion 10 | } 11 | 12 | dependencies { 13 | compile project(':core') 14 | } 15 | -------------------------------------------------------------------------------- /demo/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /core/src/main/java/com/lsxiao/apollo/core/annotations/Backpressure.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.core.annotations 2 | 3 | import io.reactivex.BackpressureStrategy 4 | 5 | /** 6 | * write with Apollo 7 | * author:lsxiao 8 | * date:2017-04-22 03:00 9 | * github:https://github.com/lsxiao 10 | * zhihu:https://zhihu.com/people/lsxiao 11 | */ 12 | 13 | annotation class Backpressure(val value: BackpressureStrategy) 14 | -------------------------------------------------------------------------------- /unittest/src/main/java/com/lsxiao/apollo/unittest/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.unittest 2 | 3 | import android.os.Bundle 4 | import android.support.v7.app.AppCompatActivity 5 | 6 | class MainActivity : AppCompatActivity() { 7 | 8 | override fun onCreate(savedInstanceState: Bundle?) { 9 | super.onCreate(savedInstanceState) 10 | setContentView(R.layout.activity_main) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/main/java/com/lsxiao/apollo/core/serialize/Serializable.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.core.serialize 2 | 3 | /** 4 | * write with Apollo 5 | * author:lsxiao 6 | * date:2017-05-17 17:23 7 | * github:https://github.com/lsxiao 8 | * zhihu:https://zhihu.com/people/lsxiao 9 | */ 10 | 11 | interface Serializable { 12 | fun serialize(obj: Any): ByteArray 13 | 14 | fun deserialize(data: ByteArray, clazz: Class): T 15 | } 16 | -------------------------------------------------------------------------------- /demo/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /unittest/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /core/src/main/java/com/lsxiao/apollo/core/annotations/Take.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.core.annotations 2 | 3 | /** 4 | * write with Apollo 5 | * author:lsxiao 6 | * date:2017-04-22 02:20 7 | * github:https://github.com/lsxiao 8 | * zhihu:https://zhihu.com/people/lsxiao 9 | */ 10 | @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) 11 | @kotlin.annotation.Retention 12 | annotation class Take(val value: Int) 13 | 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/lsxiao/apollo/core/annotations/Sticky.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.core.annotations 2 | 3 | /** 4 | * write with Apollo 5 | * author:lsxiao 6 | * date:2017-04-22 02:20 7 | * github:https://github.com/lsxiao 8 | * zhihu:https://zhihu.com/people/lsxiao 9 | */ 10 | @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) 11 | @kotlin.annotation.Retention 12 | annotation class Sticky(val remove: Boolean = true) 13 | -------------------------------------------------------------------------------- /core/src/main/java/com/lsxiao/apollo/core/contract/ApolloBinder.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.core.contract 2 | 3 | import io.reactivex.disposables.Disposable 4 | 5 | /** 6 | * write with Apollo 7 | * author:lsxiao 8 | * date:2017-02-15 22:23 9 | * github:https://github.com/lsxiao 10 | * zhihu:https://zhihu.com/people/lsxiao 11 | */ 12 | 13 | interface ApolloBinder { 14 | fun add(disposable: Disposable) 15 | 16 | fun unbind() 17 | 18 | fun isUnbind(): Boolean 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/java/com/lsxiao/apollo/core/contract/ApolloBinderGenerator.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.core.contract 2 | 3 | import com.lsxiao.apollo.core.entity.Event 4 | 5 | /** 6 | * write with Apollo 7 | * author:lsxiao 8 | * date:2017-02-15 22:21 9 | * github:https://github.com/lsxiao 10 | * zhihu:https://zhihu.com/people/lsxiao 11 | */ 12 | 13 | interface ApolloBinderGenerator { 14 | fun generate(subscriber: Any): ApolloBinder 15 | 16 | fun broadcastEvent(event: Event) 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'com.github.dcendents.android-maven' 4 | 5 | group = 'com.github.lsxiao' 6 | sourceCompatibility = 1.7 7 | targetCompatibility = 1.7 8 | 9 | dependencies { 10 | implementation fileTree(include: ['*.jar'], dir: 'libs') 11 | def test = parent.ext.test 12 | testImplementation test.junit 13 | 14 | 15 | def libs = parent.ext.libs 16 | compile libs.rxjava2 17 | compile libs.kotlin 18 | compile libs.kryo 19 | } -------------------------------------------------------------------------------- /demo/src/main/java/com/lsxiao/apollo/demo/App.java: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.demo; 2 | 3 | import android.app.Application; 4 | 5 | import com.lsxiao.apollo.core.Apollo; 6 | 7 | import io.reactivex.android.schedulers.AndroidSchedulers; 8 | 9 | 10 | /** 11 | * author lsxiao 12 | * date 2016-08-08 13:33 13 | */ 14 | public class App extends Application { 15 | @Override 16 | public void onCreate() { 17 | super.onCreate(); 18 | Apollo.init(AndroidSchedulers.mainThread(), this, true); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /demo/src/main/java/com/lsxiao/apollo/demo/constant/Event.java: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.demo.constant; 2 | 3 | /** 4 | * write with Apollo 5 | * author:lsxiao 6 | * date:2017-04-23 04:04 7 | * github:https://github.com/lsxiao 8 | * zhihu:https://zhihu.com/people/lsxiao 9 | */ 10 | 11 | public interface Event { 12 | String STR = "str"; 13 | String INT_NUMBER = "int"; 14 | String FLOAT_NUMBER = "float"; 15 | String DOBLUE_NUMBER = "double"; 16 | String BOOL = "bool"; 17 | String OBJECT = "object"; 18 | } 19 | -------------------------------------------------------------------------------- /demo/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ApolloDemo 3 | 第一activity 4 | 第二个activity 5 | 发送普通事件给第一个activity 6 | 发送sticky事件给第二个activity 7 | 移除第二个activity的sticky事件 8 | 启动第二个activity 9 | 10 | -------------------------------------------------------------------------------- /core/src/main/java/com/lsxiao/apollo/core/ProcessUtil.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.core 2 | 3 | /** 4 | * write with Apollo 5 | * author:lsxiao 6 | * date:2017-05-15 16:56 7 | * github:https://github.com/lsxiao 8 | * zhihu:https://zhihu.com/people/lsxiao 9 | */ 10 | 11 | object ProcessUtil { 12 | /** 13 | * 使用反射的方式获取进程的id(Apollo是纯java库) 14 | */ 15 | fun getPid(): Int { 16 | val threadClazz = Class.forName("android.os.Process") 17 | val method = threadClazz.getMethod("myPid") 18 | return method.invoke(null) as Int 19 | } 20 | } -------------------------------------------------------------------------------- /core/src/main/java/com/lsxiao/apollo/core/annotations/ObserveOn.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.core.annotations 2 | 3 | import com.lsxiao.apollo.core.entity.SchedulerProvider 4 | 5 | /** 6 | * write with Apollo 7 | * author:lsxiao 8 | * date:2017-04-22 02:21 9 | * github:https://github.com/lsxiao 10 | * zhihu:https://zhihu.com/people/lsxiao 11 | */ 12 | 13 | @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) 14 | @kotlin.annotation.Retention 15 | annotation class ObserveOn(val value: SchedulerProvider.Tag = SchedulerProvider.Tag.MAIN) 16 | -------------------------------------------------------------------------------- /processor/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'com.github.dcendents.android-maven' 4 | 5 | group = 'com.github.lsxiao' 6 | sourceCompatibility = 1.7 7 | targetCompatibility = 1.7 8 | 9 | dependencies { 10 | implementation fileTree(dir: 'libs', include: ['*.jar']) 11 | testImplementation parent.ext.test.junit 12 | def libs = parent.ext.libs 13 | 14 | compile project(':core') 15 | compile libs.javapoet 16 | compile libs.autoService 17 | compile libs.autoCommon 18 | compile libs.kotlin 19 | compile libs.rxjava2 20 | } -------------------------------------------------------------------------------- /core/src/main/java/com/lsxiao/apollo/core/annotations/SubscribeOn.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.core.annotations 2 | 3 | import com.lsxiao.apollo.core.entity.SchedulerProvider 4 | 5 | 6 | /** 7 | * write with Apollo 8 | * author:lsxiao 9 | * date:2017-04-22 02:21 10 | * github:https://github.com/lsxiao 11 | * zhihu:https://zhihu.com/people/lsxiao 12 | */ 13 | 14 | @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) 15 | @kotlin.annotation.Retention 16 | annotation class SubscribeOn(val value: SchedulerProvider.Tag = SchedulerProvider.Tag.IO) 17 | -------------------------------------------------------------------------------- /demo/src/main/java/com/lsxiao/apollo/demo/model/User.java: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.demo.model; 2 | 3 | /** 4 | * write with Apollo 5 | * author:lsxiao 6 | * date:2017-04-24 00:04 7 | * github:https://github.com/lsxiao 8 | * zhihu:https://zhihu.com/people/lsxiao 9 | */ 10 | 11 | public class User { 12 | String name; 13 | 14 | public User() { 15 | } 16 | 17 | public User(String name) { 18 | this.name = name; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "User{" + 24 | "name='" + name + '\'' + 25 | '}'; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | gradle.properties 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | 27 | # Log Files 28 | *.log 29 | 30 | # Android Studio Navigation editor temp files 31 | .navigation/ 32 | 33 | # Android Studio captures folder 34 | captures/ 35 | 36 | # Intellij 37 | *.iml 38 | 39 | # Keystore files 40 | *.jks 41 | 42 | .DS_Store 43 | /captures 44 | .idea -------------------------------------------------------------------------------- /demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/boluo/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /processor/src/test/java/ProcessUtilTest.kt: -------------------------------------------------------------------------------- 1 | import com.lsxiao.apllo.processor.Util 2 | import junit.framework.TestCase 3 | import org.junit.Test 4 | import java.util.* 5 | 6 | /** 7 | * write with Apollo 8 | * author:lsxiao 9 | * date:2017-04-23 11:24 10 | * github:https://github.com/lsxiao 11 | * zhihu:https://zhihu.com/people/lsxiao 12 | */ 13 | 14 | 15 | class ProcessUtilTest : TestCase() { 16 | @Test 17 | fun testSplit() { 18 | assertEquals(""""a","b","c"""", Util.split(Arrays.asList("a", "b", "c"), ",")) 19 | 20 | assertEquals(""""a","b"""", Util.split(Arrays.asList("a", "b"), ",")) 21 | 22 | assertEquals(""""a"""", Util.split(Arrays.asList("a"), ",")) 23 | 24 | assertEquals("", Util.split(Arrays.asList(), ",")) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /unittest/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /unittest/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /unittest/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /demo/src/main/java/com/lsxiao/apollo/demo/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.demo.base; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | 6 | import com.lsxiao.apollo.core.Apollo; 7 | import com.lsxiao.apollo.core.contract.ApolloBinder; 8 | 9 | 10 | public abstract class BaseActivity extends AppCompatActivity { 11 | private ApolloBinder mBinder; 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(getLayoutId()); 17 | mBinder = Apollo.bind(this); 18 | afterCreate(savedInstanceState); 19 | } 20 | 21 | @Override 22 | protected void onDestroy() { 23 | super.onDestroy(); 24 | mBinder.unbind(); 25 | } 26 | 27 | protected abstract int getLayoutId(); 28 | 29 | protected abstract void afterCreate(Bundle savedInstanceState); 30 | } 31 | -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /ipc/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/boluo/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /demo/src/main/java/com/lsxiao/apollo/demo/TestService.java: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.demo; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.IBinder; 6 | import android.os.Process; 7 | import android.support.annotation.Nullable; 8 | 9 | import com.lsxiao.apollo.core.Apollo; 10 | import com.lsxiao.apollo.demo.model.User; 11 | 12 | /** 13 | * write with Apollo 14 | * author:lsxiao 15 | * date:2017-05-15 15:18 16 | * github:https://github.com/lsxiao 17 | * zhihu:https://zhihu.com/people/lsxiao 18 | */ 19 | 20 | public class TestService extends Service { 21 | public TestService() { 22 | super(); 23 | } 24 | 25 | @Override 26 | public int onStartCommand(Intent intent, int flags, int startId) { 27 | Apollo.emit("ipc", new User("a User from TestService and pid is" + Process.myPid())); 28 | return super.onStartCommand(intent, flags, startId); 29 | } 30 | 31 | @Nullable 32 | @Override 33 | public IBinder onBind(Intent intent) { 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/com/lsxiao/apollo/core/entity/ApolloBinderImpl.kt: -------------------------------------------------------------------------------- 1 | package com.lsxiao.apollo.core.entity 2 | 3 | import com.lsxiao.apollo.core.Apollo 4 | import com.lsxiao.apollo.core.contract.ApolloBinder 5 | import io.reactivex.disposables.CompositeDisposable 6 | import io.reactivex.disposables.Disposable 7 | 8 | /** 9 | * write with Apollo 10 | * author:lsxiao 11 | * date:2017-02-15 22:27 12 | * github:https://github.com/lsxiao 13 | * zhihu:https://zhihu.com/people/lsxiao 14 | */ 15 | 16 | class ApolloBinderImpl(private val o: Any) : ApolloBinder { 17 | private val mCompositeDisposable: CompositeDisposable by lazy { 18 | CompositeDisposable() 19 | } 20 | 21 | override fun add(disposable: Disposable) { 22 | mCompositeDisposable.add(disposable) 23 | } 24 | 25 | override fun unbind() { 26 | if (!mCompositeDisposable.isDisposed) { 27 | mCompositeDisposable.clear() 28 | } 29 | Apollo.unBind(o) 30 | } 31 | 32 | override fun isUnbind(): Boolean { 33 | return mCompositeDisposable.isDisposed 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/dialog_subscriber.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 18 | 19 | 26 | 27 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 |