├── sonar-project.properties ├── rxbolts2 ├── rxbolts.pro ├── src │ └── main │ │ └── AndroidManifest.xml ├── jacoco-android-coveralls.gradle ├── javadoc.gradle ├── jacoco-coveralls.gradle ├── jacoco.gradle └── build.gradle ├── rxbolts2-applinks ├── rxbolts-applinks.pro ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── rx │ │ │ └── bolts2 │ │ │ └── AppLinkObservable.java │ └── test │ │ └── java │ │ └── rx │ │ └── bolts2 │ │ └── AppLinkObservableTests.java ├── jacoco-android-coveralls.gradle ├── javadoc.gradle ├── jacoco-coveralls.gradle ├── jacoco.gradle └── build.gradle ├── art ├── rxbolts.png ├── rxbolts2.png ├── rxbolts-gray.png ├── rxbolts-banner.png ├── rxbolts-banner-1024.png ├── rxbolts-gray-fg-blue-bg.png └── rxbolts.svg ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── rxbolts2-tasks ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── rx │ │ │ └── bolts2 │ │ │ └── RxTask.java │ └── test │ │ └── java │ │ └── rx │ │ └── bolts2 │ │ └── TaskObservableTests.java ├── javadoc.gradle └── build.gradle ├── .travis.yml ├── gradlew.bat ├── gradlew ├── README.md └── LICENSE /sonar-project.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rxbolts2/rxbolts.pro: -------------------------------------------------------------------------------- 1 | -dontwarn java.lang.invoke** 2 | -------------------------------------------------------------------------------- /rxbolts2-applinks/rxbolts-applinks.pro: -------------------------------------------------------------------------------- 1 | -dontwarn java.lang.invoke** 2 | -------------------------------------------------------------------------------- /art/rxbolts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/RxBolts/HEAD/art/rxbolts.png -------------------------------------------------------------------------------- /art/rxbolts2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/RxBolts/HEAD/art/rxbolts2.png -------------------------------------------------------------------------------- /art/rxbolts-gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/RxBolts/HEAD/art/rxbolts-gray.png -------------------------------------------------------------------------------- /art/rxbolts-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/RxBolts/HEAD/art/rxbolts-banner.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':rxbolts2-tasks' 2 | include ':rxbolts2-applinks' 3 | include ':rxbolts2' 4 | -------------------------------------------------------------------------------- /art/rxbolts-banner-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/RxBolts/HEAD/art/rxbolts-banner-1024.png -------------------------------------------------------------------------------- /art/rxbolts-gray-fg-blue-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/RxBolts/HEAD/art/rxbolts-gray-fg-blue-bg.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongjhih/RxBolts/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /rxbolts2/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /rxbolts2-applinks/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .classpath 3 | .settings/ 4 | bin/ 5 | gen/ 6 | 7 | # git 8 | *.orig 9 | 10 | # vim 11 | *.sw* 12 | *~ 13 | 14 | build/ 15 | .gradle/ 16 | .idea/ 17 | .apt_generated/ 18 | *.iml 19 | 20 | local.properties 21 | -------------------------------------------------------------------------------- /rxbolts2-tasks/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Apr 04 14:22:26 BRT 2016 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-2.10-all.zip 7 | -------------------------------------------------------------------------------- /rxbolts2/jacoco-android-coveralls.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.github.kt3k.coveralls' 2 | 3 | coveralls { 4 | jacocoReportPath "$buildDir/reports/jacoco/jacocoTestDebugUnitTestReport/jacocoTestDebugUnitTestReport.xml" 5 | } 6 | 7 | tasks.coveralls { 8 | dependsOn 'jacocoTestReport' 9 | } 10 | -------------------------------------------------------------------------------- /rxbolts2-applinks/jacoco-android-coveralls.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.github.kt3k.coveralls' 2 | 3 | coveralls { 4 | jacocoReportPath "$buildDir/reports/jacoco/jacocoTestDebugUnitTestReport/jacocoTestDebugUnitTestReport.xml" 5 | } 6 | 7 | tasks.coveralls { 8 | dependsOn 'jacocoTestReport' 9 | } 10 | -------------------------------------------------------------------------------- /rxbolts2-tasks/javadoc.gradle: -------------------------------------------------------------------------------- 1 | // build a jar with source files 2 | task sourcesJar(type: Jar) { 3 | classifier = 'sources' 4 | from sourceSets.main.allJava 5 | } 6 | 7 | // build a jar with javadoc 8 | task javadocJar(type: Jar, dependsOn: javadoc) { 9 | classifier = 'javadoc' 10 | from javadoc.destinationDir 11 | } 12 | 13 | artifacts { 14 | archives sourcesJar 15 | archives javadocJar 16 | } 17 | -------------------------------------------------------------------------------- /rxbolts2/javadoc.gradle: -------------------------------------------------------------------------------- 1 | // build a jar with source files 2 | task sourcesJar(type: Jar) { 3 | from android.sourceSets.main.java.srcDirs 4 | classifier = 'sources' 5 | } 6 | 7 | task javadoc(type: Javadoc) { 8 | failOnError false 9 | source = android.sourceSets.main.java.sourceFiles 10 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 11 | } 12 | 13 | // build a jar with javadoc 14 | task javadocJar(type: Jar, dependsOn: javadoc) { 15 | classifier = 'javadoc' 16 | from javadoc.destinationDir 17 | } 18 | 19 | artifacts { 20 | archives sourcesJar 21 | archives javadocJar 22 | } 23 | -------------------------------------------------------------------------------- /rxbolts2-applinks/javadoc.gradle: -------------------------------------------------------------------------------- 1 | // build a jar with source files 2 | task sourcesJar(type: Jar) { 3 | from android.sourceSets.main.java.srcDirs 4 | classifier = 'sources' 5 | } 6 | 7 | task javadoc(type: Javadoc) { 8 | failOnError false 9 | source = android.sourceSets.main.java.sourceFiles 10 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 11 | } 12 | 13 | // build a jar with javadoc 14 | task javadocJar(type: Jar, dependsOn: javadoc) { 15 | classifier = 'javadoc' 16 | from javadoc.destinationDir 17 | } 18 | 19 | artifacts { 20 | archives sourcesJar 21 | archives javadocJar 22 | } 23 | -------------------------------------------------------------------------------- /rxbolts2/jacoco-coveralls.gradle: -------------------------------------------------------------------------------- 1 | // Setup: classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3' 2 | 3 | // ref. http://stackoverflow.com/questions/29133761/jacoco-code-coverage-in-android-studio 4 | apply plugin: 'com.github.kt3k.coveralls' 5 | 6 | coveralls { 7 | //jacocoReportPath "$buildDir/reports/coverage/debug/report.xml" // Instrumentation 8 | //jacocoReportPath "$buildDir/reports/jacoco/jacocoTestDebugUnitTestReport/jacocoTestDebugUnitTestReport.xml" // jacoco-android 9 | jacocoReportPath "$buildDir/reports/jacoco/jacocoTestReport/jacocoTestReport.xml" // jacoco.gradle 10 | } 11 | 12 | tasks.coveralls { 13 | //dependsOn 'createDebugCoverageReport' // Instrumentation 14 | dependsOn 'jacocoTestReport' 15 | } 16 | 17 | ////apply plugin: 'jacoco-android' 18 | apply from: 'jacoco.gradle' 19 | -------------------------------------------------------------------------------- /rxbolts2-applinks/jacoco-coveralls.gradle: -------------------------------------------------------------------------------- 1 | // Setup: classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3' 2 | 3 | // ref. http://stackoverflow.com/questions/29133761/jacoco-code-coverage-in-android-studio 4 | apply plugin: 'com.github.kt3k.coveralls' 5 | 6 | coveralls { 7 | //jacocoReportPath "$buildDir/reports/coverage/debug/report.xml" // Instrumentation 8 | //jacocoReportPath "$buildDir/reports/jacoco/jacocoTestDebugUnitTestReport/jacocoTestDebugUnitTestReport.xml" // jacoco-android 9 | jacocoReportPath "$buildDir/reports/jacoco/jacocoTestReport/jacocoTestReport.xml" // jacoco.gradle 10 | } 11 | 12 | tasks.coveralls { 13 | //dependsOn 'createDebugCoverageReport' // Instrumentation 14 | dependsOn 'jacocoTestReport' 15 | } 16 | 17 | ////apply plugin: 'jacoco-android' 18 | apply from: 'jacoco.gradle' 19 | -------------------------------------------------------------------------------- /rxbolts2/jacoco.gradle: -------------------------------------------------------------------------------- 1 | // ref. https://github.com/adelnizamutdinov/headphone-reminder/blob/master/app/build.gradle 2 | apply plugin: 'jacoco' 3 | 4 | final jacocoExcludes = [ 5 | '**/R*.class', 6 | '**/BuildConfig*', 7 | "**/*Package.class" 8 | ] 9 | 10 | 11 | task jacocoTestReport(type: JacocoReport, dependsOn: 'testDebugUnitTest') { 12 | reports { 13 | xml.enabled = true 14 | html.enabled = true 15 | } 16 | 17 | classDirectories = fileTree(dir: 'build/intermediates/classes/debug', excludes: jacocoExcludes) 18 | sourceDirectories = files("src/main/java") 19 | executionData = files("build/jacoco/testDebugUnitTest.exec") 20 | 21 | doFirst { 22 | file('build/intermediates/classes/debug').eachFileRecurse { file -> 23 | if (file.name.contains('$$')) { 24 | file.renameTo(file.path.replace('$$', '$')) 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /rxbolts2-applinks/jacoco.gradle: -------------------------------------------------------------------------------- 1 | // ref. https://github.com/adelnizamutdinov/headphone-reminder/blob/master/app/build.gradle 2 | apply plugin: 'jacoco' 3 | 4 | final jacocoExcludes = [ 5 | '**/R*.class', 6 | '**/BuildConfig*', 7 | "**/*Package.class" 8 | ] 9 | 10 | 11 | task jacocoTestReport(type: JacocoReport, dependsOn: 'testDebugUnitTest') { 12 | reports { 13 | xml.enabled = true 14 | html.enabled = true 15 | } 16 | 17 | classDirectories = fileTree(dir: 'build/intermediates/classes/debug', excludes: jacocoExcludes) 18 | sourceDirectories = files("src/main/java") 19 | executionData = files("build/jacoco/testDebugUnitTest.exec") 20 | 21 | doFirst { 22 | file('build/intermediates/classes/debug').eachFileRecurse { file -> 23 | if (file.name.contains('$$')) { 24 | file.renameTo(file.path.replace('$$', '$')) 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: 3 | - oraclejdk7 4 | - oraclejdk8 5 | android: 6 | components: 7 | - platform-tools 8 | - tools 9 | - build-tools-22.0.1 10 | - android-22 11 | - build-tools-23.0.1 12 | - android-23 13 | - extra-android-support 14 | - extra-android-m2repository 15 | before_install: 16 | - export JAVA7_HOME=/usr/lib/jvm/java-7-oracle 17 | - export JAVA8_HOME=/usr/lib/jvm/java-8-oracle 18 | - export JAVA_HOME=$JAVA8_HOME 19 | script: 20 | - ./gradlew clean assemble check 21 | after_success: 22 | - ./gradlew coveralls 23 | 24 | # as per http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/ 25 | sudo: false 26 | 27 | addons: 28 | sonarqube: 29 | token: 30 | secure: "UojdV/+CwMCbX2UNhS+BAXe/3Fb63fCNG/54Yd3hvkGDo6jkicrPjVT3v1R55WbFpDbOmn1ot+SxPso0sKoUIBCT7r095XS7wyae5ISSveRwm1b2corLUEwEFYIPxYFAxAaPOP1QjeYf08vJYDGJ7eSytSRjm20hSed3+qfYO7Xd3MTXhR2w0oKnHSmXfn0ry+N4LYg8hYrNjx+//1TcCyhCz/ceC+G5p0DjKI1GF4T8P3wrl9w3lmzw1ZG8xIbyCrVdyFydGkQP3kVuNLAsbwPLM9AlXbDI5eJv4Yyl7uBdQwnN2nvnHCYp/If7mWTQtNxabUHqJS+FPeEpSLh3gizUE3/2Wwq7LV27sib5d65rWQKhiFVJPl4ymzj4gtBGU4BbykmOSbHGqp2euuJnHFyfkZiPnlT6utzrYwkY/vKdsXhKuO6m/DTZynmwcTVu7/6hcGamaA/hNpsYmUk3hgeRzdtko44ojtWAARDNHZXKlwv+HxNMTqbHaGj7vpcPhUrkLQo76WKCrqDM5QFzAd3QHC/tGnsOf5hoRWjHLug/LlIMZD4YpVq2Btf0dfw4g7BDruH0teWxG2zdIK+9RF5hCZKlqq5R2ZmlwYdcMRK8taw7ZKX4WyVFvnWnnCjHFZ0VrlcTi/9ZUT36m4hy1m1Gch39EOkqZ8/4ven+lyI=" 31 | github_token: 32 | secure: "TLGPPSsT4g/ZWfU2zgC12sdNZvlzyPGuJhpD1scJCa71wdjBvLWaeEtQGNoYZQoP2SgKU9+J6AUl1skAXk1a1veAM6VHdKifmZwu3S54Zhj8oAZVVmbeUhhPC+SBT0lkuxPJ8hEhX4MulBb+5Ij/M0+WxiycWuwRZTZDfj3uWhTbEt1OaFrbIjzdKkVz1Tn9uSuZiKvDQKNp/o/HZvzj2UBjPZYkHwJePJGu2v7gHqPc1OqUNqx+xxaoBOoBFJg0wKDY6uruxw8Yno1Ujedl07uTAlnPcGyQUPyM6JN80sFXZi21tCcYT9SiJ9UE8opc/M6scF0Qt4APwxvzSdWLE96W6Wh2eF8KNpfJKrasp+gg8J2MsgI9pcdF3qaE4aCUVuIKoAq0TKJ5wkqVXZYA4qMu9DqoQsOrNu2Rqmjl7TGRV+lX6nRKSQH/HyqgLiqExY2MkouIoxdcHp4LjY/DWVbIsgWclh11SRJNm6Fdnr54GQj8NOgNo51k8ZX/a/AuJGZLkwhOVwGCq5JAmJPjGXuH8nM+t1CdjfyvkgTYSpEPb6SvpwkPVa/osg5VOmpzwbrJtjtjEgQdFbb3E50QzdtN1ljLkyq+1tYyw1u5SMEvPEhznvRoXZtGAccwDQxOyqi6hg8VAjyvoTajr9q+I2ntoy3VVbaN/SFkwtaT/Fk=" 33 | script: 34 | # other script steps might be done before running the actual SonarQube analysis 35 | - sonar-scanner 36 | -------------------------------------------------------------------------------- /rxbolts2-tasks/src/test/java/rx/bolts2/TaskObservableTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 8tory, Inc 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package rx.bolts2; 18 | 19 | import org.junit.Test; 20 | 21 | import bolts.Task; 22 | import io.reactivex.Observable; 23 | import io.reactivex.functions.Consumer; 24 | import io.reactivex.functions.Predicate; 25 | 26 | import static org.assertj.core.api.Assertions.assertThat; 27 | 28 | 29 | public class TaskObservableTests { 30 | 31 | @Test 32 | public void single() { 33 | RxTask.single(Task.forResult(null)) 34 | .test() 35 | .assertError(NullPointerException.class); 36 | 37 | RxTask.single(Task.forResult("hello")) 38 | .test() 39 | .assertValue(check(v -> assertThat(v).isEqualTo("hello"))) 40 | .assertNoErrors() 41 | .assertComplete(); 42 | } 43 | 44 | @Test 45 | public void completable() { 46 | RxTask.completable(Task.forResult(null)) 47 | .test() 48 | .assertError(NullPointerException.class); 49 | 50 | RxTask.completable(Task.forResult("hello")) 51 | .test() 52 | .assertValue(check(v -> assertThat(v).isEqualTo("hello"))) 53 | .assertNoErrors() 54 | .assertComplete(); 55 | } 56 | @Test 57 | public void observable() { 58 | RxTask.observable(Task.forResult(null)) 59 | .test() 60 | .assertError(NullPointerException.class); 61 | 62 | RxTask.observable(Task.forResult("hello")) 63 | .test() 64 | .assertValue(check(v -> assertThat(v).isEqualTo("hello"))) 65 | .assertNoErrors() 66 | .assertComplete(); 67 | } 68 | 69 | @Test 70 | public void forTaskObservable() { 71 | assertThat(RxTask.forTask(Observable.empty()).getResult()).isNull(); 72 | } 73 | 74 | public static Predicate check(Consumer consumer) { 75 | return t -> { 76 | consumer.accept(t); 77 | return true; 78 | }; 79 | } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /rxbolts2/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:2.1.0' 8 | classpath 'me.tatarka:gradle-retrolambda:2.5.0' 9 | classpath 'com.novoda:bintray-release:0.3.4' 10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' 11 | classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3' 12 | } 13 | } 14 | 15 | apply plugin: 'com.android.library' 16 | apply plugin: 'me.tatarka.retrolambda' 17 | 18 | repositories { 19 | jcenter() 20 | maven { url "https://jitpack.io" } 21 | } 22 | 23 | android { 24 | compileSdkVersion 22 25 | buildToolsVersion "22.0.1" 26 | 27 | compileOptions { 28 | sourceCompatibility JavaVersion.VERSION_1_8 29 | targetCompatibility JavaVersion.VERSION_1_8 30 | } 31 | 32 | defaultConfig { 33 | minSdkVersion 8 34 | targetSdkVersion 22 35 | 36 | consumerProguardFiles fileTree(dir: '.', include: '*.pro') 37 | } 38 | 39 | buildTypes { 40 | debug { 41 | testCoverageEnabled true // Instrumentation 42 | } 43 | } 44 | } 45 | 46 | dependencies { 47 | compile project(':rxbolts2-tasks') 48 | compile project(':rxbolts2-applinks') 49 | 50 | testCompile 'junit:junit:4.12' 51 | //testCompile 'org.robolectric:robolectric:3.0' 52 | testCompile 'org.robolectric:robolectric:3.1-rc1' 53 | //testCompile 'org.robolectric:robolectric:3.1-SNAPSHOT' 54 | testCompile 'org.mockito:mockito-core:1.10.19' 55 | testCompile 'com.squareup.okhttp:mockwebserver:2.4.0' 56 | testCompile 'io.reactivex.rxjava2:rxjava:2.0.1' 57 | testCompile 'com.github.yongjhih:mocker:0.1.2' 58 | } 59 | 60 | tasks.withType(JavaCompile) { 61 | options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked" 62 | } 63 | 64 | apply plugin: 'com.novoda.bintray-release' 65 | 66 | def getRepositoryUsername() { 67 | return hasProperty('BINTRAY_USER') ? BINTRAY_USER : "" 68 | } 69 | 70 | def getRepositoryPassword() { 71 | return hasProperty('BINTRAY_KEY') ? BINTRAY_KEY : "" 72 | } 73 | 74 | publish { 75 | userOrg = 'yongjhih' 76 | groupId = 'com.infstory' 77 | artifactId = 'rxbolts2' 78 | publishVersion = '2.0.0' 79 | desc = 'Reactive Bolts-Android.' 80 | website = 'https://github.com/yongjhih/RxBolts' 81 | bintrayUser = getRepositoryUsername() 82 | bintrayKey = getRepositoryPassword() 83 | dryRun = false 84 | } 85 | 86 | apply plugin: 'com.github.dcendents.android-maven' 87 | apply from: 'javadoc.gradle' 88 | apply from: 'jacoco-coveralls.gradle' 89 | 90 | tasks.withType(Test) { 91 | testLogging { 92 | exceptionFormat "full" 93 | events "passed", "skipped", "failed", "standardOut", "standardError" 94 | showStandardStreams = true 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /rxbolts2-applinks/src/test/java/rx/bolts2/AppLinkObservableTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 8tory, Inc 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package rx.bolts2; 18 | 19 | import org.junit.Test; 20 | //import bolts.Task; 21 | 22 | //import static org.mockito.Matchers.any; 23 | //import static org.mockito.Mockito.mock; 24 | //import static org.mockito.Mockito.times; 25 | //import static org.mockito.Mockito.verify; 26 | //import static org.mockito.Mockito.when; 27 | //import static org.mockito.Mockito.doReturn; 28 | //import static mocker.Mocker.mocker; 29 | //import mocker.Mocker; 30 | 31 | import org.junit.runner.RunWith; 32 | import org.robolectric.RobolectricTestRunner; 33 | //import org.robolectric.RuntimeEnvironment; 34 | 35 | //import rx.Observable; 36 | 37 | @RunWith(RobolectricTestRunner.class) // 38 | public class AppLinkObservableTests { 39 | 40 | @Test 41 | public void navigate() { 42 | //final Application application = RuntimeEnvironment.application; 43 | //public static Observable navigate(application, java.lang.String destinationUrl) { 44 | //public static Observable navigate(android.content.Context context, java.lang.String destinationUrl, AppLinkResolver resolver) { 45 | //public static Observable navigate(android.content.Context context, java.lang.String destinationUrl, AppLinkResolver resolver) { 46 | //public static Observable navigate(android.content.Context context, java.lang.String destinationUrl, AppLinkResolver resolver) { 47 | //public static Observable navigate(android.content.Context context, java.lang.String destinationUrl, AppLinkResolver resolver) { 48 | //public static Observable navigate(android.content.Context context, java.lang.String destinationUrl, AppLinkResolver resolver) { 49 | } 50 | 51 | @Test 52 | public void getAppLink() { 53 | //final Application application = RuntimeEnvironment.application; 54 | //public static Observable navigate(android.content.Context context, java.lang.String destinationUrl, AppLinkResolver resolver) { 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /rxbolts2-applinks/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:2.1.0' 8 | classpath 'me.tatarka:gradle-retrolambda:2.5.0' 9 | classpath 'com.novoda:bintray-release:0.3.4' 10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' 11 | classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3' 12 | } 13 | } 14 | 15 | apply plugin: 'com.android.library' 16 | apply plugin: 'me.tatarka.retrolambda' 17 | 18 | repositories { 19 | jcenter() 20 | maven { url "https://jitpack.io" } 21 | } 22 | 23 | android { 24 | compileSdkVersion 22 25 | buildToolsVersion "22.0.1" 26 | 27 | compileOptions { 28 | sourceCompatibility JavaVersion.VERSION_1_8 29 | targetCompatibility JavaVersion.VERSION_1_8 30 | } 31 | 32 | defaultConfig { 33 | minSdkVersion 8 34 | targetSdkVersion 22 35 | 36 | consumerProguardFiles fileTree(dir: '.', include: '*.pro') 37 | } 38 | 39 | buildTypes { 40 | debug { 41 | testCoverageEnabled true // Instrumentation 42 | } 43 | } 44 | } 45 | 46 | dependencies { 47 | compile 'io.reactivex.rxjava2:rxjava:2.0.1' 48 | 49 | compile 'com.parse.bolts:bolts-tasks:1.4.0' 50 | compile 'com.parse.bolts:bolts-applinks:1.4.0' 51 | compile project(':rxbolts2-tasks') 52 | 53 | testCompile 'junit:junit:4.12' 54 | //testCompile 'org.robolectric:robolectric:3.0' 55 | testCompile 'org.robolectric:robolectric:3.1-rc1' 56 | //testCompile 'org.robolectric:robolectric:3.1-SNAPSHOT' 57 | testCompile 'org.mockito:mockito-core:1.10.19' 58 | testCompile 'com.squareup.okhttp:mockwebserver:2.4.0' 59 | testCompile 'com.github.yongjhih:mocker:0.1.2' 60 | } 61 | 62 | tasks.withType(JavaCompile) { 63 | options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked" 64 | } 65 | 66 | apply plugin: 'com.novoda.bintray-release' 67 | 68 | def getRepositoryUsername() { 69 | return hasProperty('BINTRAY_USER') ? BINTRAY_USER : "" 70 | } 71 | 72 | def getRepositoryPassword() { 73 | return hasProperty('BINTRAY_KEY') ? BINTRAY_KEY : "" 74 | } 75 | 76 | publish { 77 | userOrg = 'yongjhih' 78 | groupId = 'com.infstory' 79 | artifactId = 'rxbolts2-applinks' 80 | publishVersion = '2.0.0' 81 | desc = 'Reactive Bolts-Android.' 82 | website = 'https://github.com/yongjhih/RxBolts' 83 | bintrayUser = getRepositoryUsername() 84 | bintrayKey = getRepositoryPassword() 85 | dryRun = false 86 | } 87 | 88 | apply plugin: 'com.github.dcendents.android-maven' 89 | apply from: 'javadoc.gradle' 90 | apply from: 'jacoco-coveralls.gradle' 91 | 92 | tasks.withType(Test) { 93 | testLogging { 94 | exceptionFormat "full" 95 | events "passed", "skipped", "failed", "standardOut", "standardError" 96 | showStandardStreams = true 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /rxbolts2-applinks/src/main/java/rx/bolts2/AppLinkObservable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 8tory, Inc 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package rx.bolts2; 18 | 19 | import bolts.*; 20 | import io.reactivex.Single; 21 | import io.reactivex.annotations.CheckReturnValue; 22 | import io.reactivex.annotations.NonNull; 23 | 24 | public class AppLinkObservable { 25 | @CheckReturnValue 26 | @NonNull 27 | public static Single navigate(android.content.Context context, java.lang.String destinationUrl) { 28 | return RxTask.single(() -> AppLinkNavigation.navigateInBackground(context, destinationUrl)); 29 | } 30 | @CheckReturnValue 31 | @NonNull 32 | public static Single navigate(android.content.Context context, java.lang.String destinationUrl, AppLinkResolver resolver) { 33 | return RxTask.single(() -> AppLinkNavigation.navigateInBackground(context, destinationUrl, resolver)); 34 | } 35 | @CheckReturnValue 36 | @NonNull 37 | public static Single navigate(android.content.Context context, android.net.Uri destination) { 38 | return RxTask.single(() -> AppLinkNavigation.navigateInBackground(context, destination)); 39 | } 40 | @CheckReturnValue 41 | @NonNull 42 | public static Single navigate(android.content.Context context, android.net.Uri destination, AppLinkResolver resolver) { 43 | return RxTask.single(() -> AppLinkNavigation.navigateInBackground(context, destination, resolver)); 44 | } 45 | @CheckReturnValue 46 | @NonNull 47 | public static Single navigate(android.content.Context context, java.net.URL destination) { 48 | return RxTask.single(() -> AppLinkNavigation.navigateInBackground(context, destination)); 49 | } 50 | @CheckReturnValue 51 | @NonNull 52 | public static Single navigate(android.content.Context context, java.net.URL destination, AppLinkResolver resolver) { 53 | return RxTask.single(() -> AppLinkNavigation.navigateInBackground(context, destination, resolver)); 54 | } 55 | @CheckReturnValue 56 | @NonNull 57 | public static Single getAppLink(AppLinkResolver resolver, android.net.Uri url) { 58 | return RxTask.single(() -> resolver.getAppLinkFromUrlInBackground(url)); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /rxbolts2-tasks/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | 6 | dependencies { 7 | classpath 'me.tatarka:gradle-retrolambda:2.5.0' 8 | classpath 'com.novoda:bintray-release:0.3.4' 9 | classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3' 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'me.tatarka.retrolambda' 15 | 16 | targetCompatibility = '1.8' 17 | sourceCompatibility = '1.8' 18 | 19 | retrolambda { 20 | // ```bash 21 | // export JAVA8_HOME="/usr/lib/jvm/java-8-oracle" 22 | // export JAVA7_HOME="/usr/lib/jvm/java-7-oracle" 23 | // export JAVA_HOME="$JAVA8_HOME" 24 | // ``` 25 | //jvmArgs '-noverify' 26 | jdk System.getenv("JAVA8_HOME") 27 | //oldJdk System.getenv("JAVA_HOME") 28 | oldJdk System.getenv("JAVA7_HOME") 29 | javaVersion JavaVersion.VERSION_1_7 30 | } 31 | 32 | repositories { 33 | jcenter() 34 | maven { url "https://jitpack.io" } 35 | } 36 | 37 | dependencies { 38 | compile 'io.reactivex.rxjava2:rxjava:2.0.8' 39 | 40 | compile 'com.parse.bolts:bolts-tasks:1.4.0' 41 | 42 | testCompile 'junit:junit:4.12' 43 | testCompile 'org.mockito:mockito-core:1.10.19' 44 | testCompile 'com.squareup.okhttp:mockwebserver:2.4.0' 45 | testCompile 'com.github.yongjhih:mocker:0.1.2' 46 | testCompile 'org.assertj:assertj-core:2.6.0' 47 | } 48 | 49 | tasks.withType(JavaCompile) { 50 | options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked" 51 | } 52 | 53 | apply plugin: 'com.novoda.bintray-release' 54 | 55 | def getRepositoryUsername() { 56 | return hasProperty('BINTRAY_USER') ? BINTRAY_USER : "" 57 | } 58 | 59 | def getRepositoryPassword() { 60 | return hasProperty('BINTRAY_KEY') ? BINTRAY_KEY : "" 61 | } 62 | 63 | publish { 64 | userOrg = 'yongjhih' 65 | groupId = 'com.infstory' 66 | artifactId = 'rxbolts2-tasks' 67 | publishVersion = '2.0.0' 68 | desc = 'Reactive Bolts.' 69 | website = 'https://github.com/yongjhih/RxBolts' 70 | bintrayUser = getRepositoryUsername() 71 | bintrayKey = getRepositoryPassword() 72 | dryRun = false 73 | } 74 | 75 | apply plugin: 'maven' 76 | apply from: 'javadoc.gradle' 77 | 78 | apply plugin: 'jacoco' 79 | 80 | jacocoTestReport { 81 | reports { 82 | xml.enabled = true // coveralls plugin depends on xml format report 83 | html.enabled = true 84 | } 85 | } 86 | 87 | apply plugin: 'com.github.kt3k.coveralls' 88 | 89 | coveralls { 90 | jacocoReportPath "$buildDir/reports/jacoco/test/jacocoTestReport.xml" 91 | } 92 | 93 | tasks.coveralls { 94 | dependsOn 'jacocoTestReport' 95 | } 96 | 97 | tasks.jacocoTestReport { 98 | dependsOn 'test' 99 | } 100 | 101 | tasks.withType(Test) { 102 | testLogging { 103 | exceptionFormat "full" 104 | events "passed", "skipped", "failed", "standardOut", "standardError" 105 | showStandardStreams = true 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /rxbolts2-tasks/src/main/java/rx/bolts2/RxTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 8tory, Inc 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package rx.bolts2; 18 | 19 | import java.util.concurrent.Callable; 20 | 21 | import bolts.Task; 22 | import io.reactivex.Completable; 23 | import io.reactivex.Observable; 24 | import io.reactivex.Single; 25 | import io.reactivex.annotations.CheckReturnValue; 26 | import io.reactivex.annotations.NonNull; 27 | 28 | /** 29 | * Bolts2Rx 30 | * Bolts.Task2Observable 31 | * RxBolts 32 | * RxTask 33 | * BoltsObservable 34 | * TaskObservable 35 | */ 36 | public class RxTask { 37 | 38 | @CheckReturnValue 39 | @NonNull 40 | public static Task forTask(@NonNull final Observable obs){ 41 | return Task.callInBackground(() -> obs.blockingSingle()); // FIXME: null is not acceptable 42 | } 43 | 44 | @CheckReturnValue 45 | @NonNull 46 | public static Task forTask(@NonNull final Single single){ 47 | return Task.callInBackground(() -> single.blockingGet()); // FIXME: null is not acceptable 48 | } 49 | 50 | //@CheckReturnValue 51 | //@NonNull 52 | //public static Task forTask(@NonNull final Completable completable){ 53 | // return Task.callInBackground(() -> Task.forResult(completable.blockingAwait())); // FIXME: null is not acceptable 54 | //} 55 | 56 | @CheckReturnValue 57 | @NonNull 58 | public static Observable observable(@NonNull final Task task) { 59 | return Observable.create(emitter -> { 60 | task.continueWith(t -> { 61 | if (emitter.isDisposed()) return null; 62 | 63 | if (t.isCancelled()) { 64 | // NOTICE: doOnUnsubscribe(() -> Observable.just(query) in outside 65 | emitter.onComplete(); 66 | } else if (t.isFaulted()) { 67 | Throwable error = t.getError(); 68 | emitter.onError(error); 69 | } else { 70 | R r = t.getResult(); 71 | if (r != null) emitter.onNext(r); 72 | emitter.onComplete(); 73 | } 74 | return null; 75 | }); 76 | }); 77 | // TODO .doOnUnsubscribe(() -> task.setCancelled()); 78 | } 79 | 80 | @NonNull 81 | public static Completable completable(@NonNull final Task task) { 82 | return Completable.create(emitter -> { 83 | task.continueWith(t -> { 84 | if (emitter.isDisposed()) return null; 85 | 86 | if (t.isCancelled()) { 87 | // NOTICE: doOnUnsubscribe(() -> Observable.just(query) in outside 88 | emitter.onComplete(); 89 | } else if (t.isFaulted()) { 90 | Throwable error = t.getError(); 91 | emitter.onError(error); 92 | } else { 93 | t.getResult(); 94 | emitter.onComplete(); 95 | } 96 | return null; 97 | }); 98 | }); 99 | // TODO .doOnUnsubscribe(() -> task.setCancelled()); 100 | } 101 | 102 | /** 103 | * Please don't put the Task<Void> as parameter 104 | * @param task 105 | * @param 106 | * @return 107 | */ 108 | @CheckReturnValue 109 | @NonNull 110 | public static Single single(@NonNull final Task task) { 111 | return Single.create(emitter -> { 112 | task.continueWith(t -> { 113 | if (emitter.isDisposed()) return null; 114 | 115 | if (t.isCancelled()) { 116 | emitter.onError(new RuntimeException("Cancelled task")); 117 | } else if (t.isFaulted()) { 118 | Throwable error = t.getError(); 119 | emitter.onError(error); 120 | } else { 121 | R r = t.getResult(); 122 | emitter.onSuccess(r); 123 | } 124 | return null; 125 | }); 126 | }); 127 | // TODO .doOnUnsubscribe(() -> task.setCancelled()); 128 | } 129 | 130 | /** 131 | * Please use observable(Callable) instead of this for defer unless you know what are you doing 132 | * Please don't put the Task<Void> as parameter 133 | * @param task 134 | * @param 135 | * @return 136 | */ 137 | @CheckReturnValue 138 | @NonNull 139 | public static Observable observable(@NonNull final Callable> task) { 140 | return Single.fromCallable(task).flatMapObservable(RxTask::observable); 141 | } 142 | 143 | /** 144 | * Please use single(Callable) instead of this for defer unless you know what are you doing 145 | * Please don't put the Task<Void> as parameter 146 | * @param task 147 | * @param 148 | * @return 149 | */ 150 | @CheckReturnValue 151 | @NonNull 152 | public static Single single(@NonNull final Callable> task) { 153 | return Single.fromCallable(task).flatMap(RxTask::single); 154 | } 155 | 156 | /** 157 | * Please use single(Callable) instead of this for defer unless you know what are you doing 158 | * @param task 159 | * @param 160 | * @return 161 | */ 162 | @NonNull 163 | public static Completable completable(@NonNull final Callable> task) { 164 | return Single.fromCallable(task).flatMapCompletable(RxTask::completable); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RxBolts 2 | 3 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-RxBolts-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/2645) 4 | [![JitPack](https://img.shields.io/github/tag/yongjhih/RxBolts.svg?label=JitPack)](https://jitpack.io/#yongjhih/RxBolts) 5 | [![Download](https://api.bintray.com/packages/yongjhih/maven/rxbolts/images/download.svg) ](https://bintray.com/yongjhih/maven/rxbolts/_latestVersion) 6 | [![javadoc](https://img.shields.io/github/tag/yongjhih/RxBolts.svg?label=javadoc)](https://jitpack.io/com/github/yongjhih/RxBolts/rxbolts-tasks/-SNAPSHOT/javadoc/) 7 | [![Build Status](https://travis-ci.org/yongjhih/RxBolts.svg)](https://travis-ci.org/yongjhih/RxBolts) 8 | [![Methods Count](https://img.shields.io/badge/Methods and size-core: 54 | deps: 4111 | 6 KB-e91e63.svg)](http://www.methodscount.com/?lib=com.infstory%3Arxbolts%3A1.0.0) 9 | [![Gitter Chat](https://img.shields.io/gitter/room/yongjhih/RxBolts.svg)](https://gitter.im/yongjhih/RxBolts) 10 | [![Coverage Status](https://coveralls.io/repos/github/yongjhih/RxBolts/badge.svg)](https://coveralls.io/github/yongjhih/RxBolts) 11 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/05a9b9b101b24073bc021f41bafc5090)](https://codacy.com/app/yongjhih/RxBolts) 12 | 13 | 14 | 15 | 16 | 17 | ![](art/rxbolts2.png) 18 | 19 | Reactive [Bolts-Android](https://github.com/BoltsFramework/Bolts-Android). Allow convert `Task` to `Observable`. 20 | 21 | ## Usage 22 | 23 | TaskObservable.defer(): 24 | 25 | ```java 26 | TaskObservable.defer(() -> Task.forResult("Hello, world!")).subscribe(it -> { 27 | System.out.println(it); 28 | }); 29 | ``` 30 | 31 | Take 5 users using Parse: 32 | 33 | ```java 34 | TaskObservable.defer(() -> ParseUser.getQuery().findInBackground()).flatMap(Observable::from).take(5).subscribe(user -> { 35 | System.out.println(user.getObjserId()); 36 | }); 37 | ``` 38 | 39 | Update location of 5 users using Parse: 40 | 41 | ```java 42 | TaskObservable.defer(() -> ParseUser.getQuery().findInBackground()).flatMap(Observable::from).take(5).flatMap(user -> { 43 | user.put("location", "Taipei"); 44 | return TaskObservable.defer(() -> user.saveInBackground()); 45 | }).subscribe(); 46 | ``` 47 | 48 | ### Error handling 49 | 50 | Failed: 51 | 52 | ```java 53 | TaskObservable.defer(() -> Task.forError(new RuntimeException("An error message."))).subscribe(it -> {}, e -> { 54 | e.printStackTrace(); // RuntimeException 55 | }); 56 | ``` 57 | 58 | ## AppLinks 59 | 60 | [![javadoc](https://img.shields.io/github/tag/yongjhih/RxBolts.svg?label=javadoc)](https://jitpack.io/com/github/yongjhih/RxBolts/rxbolts-applinks/-SNAPSHOT/javadoc/) 61 | 62 | ```java 63 | AppLinkObservable.navigate(context, url, resolver); 64 | ``` 65 | 66 | ```java 67 | AppLinkNavigation.setDefaultResolver(resolver); 68 | AppLinkObservable.navigate(context, url); 69 | ``` 70 | 71 | ## Sample code 72 | 73 | * https://github.com/yongjhih/RxParse/blob/master/rxparse/src/main/java/rx/parse/ParseObservable.java 74 | 75 | ## Installation 76 | 77 | ### For RxJava2 78 | 79 | Via jitpack.io 80 | 81 | ```gradle 82 | repositories { 83 | jcenter() 84 | maven { url "https://jitpack.io" } 85 | } 86 | 87 | dependencies { 88 | compile 'com.github.yongjhih.RxBolts:rxbolts2:-SNAPSHOT' 89 | //compile 'com.github.yongjhih.RxBolts:rxbolts2-taks:-SNAPSHOT' 90 | //compile 'com.github.yongjhih.RxBolts:rxbolts2-applinks:-SNAPSHOT' 91 | } 92 | ``` 93 | 94 | ### For RxJava1 95 | 96 | via jcenter 97 | 98 | ```gradle 99 | repositories { 100 | jcenter() 101 | 102 | } 103 | 104 | dependencies { 105 | compile 'com.infstory:rxbolts:1.0.1' 106 | } 107 | ``` 108 | 109 | Or via jitpack.io 110 | 111 | ```gradle 112 | repositories { 113 | jcenter() 114 | maven { url "https://jitpack.io" } 115 | } 116 | 117 | dependencies { 118 | compile 'com.github.yongjhih.RxBolts:rxbolts:-SNAPSHOT' 119 | //compile 'com.github.yongjhih.RxBolts:rxbolts-tasks:-SNAPSHOT' 120 | //compile 'com.github.yongjhih.RxBolts:rxbolts-applinks:-SNAPSHOT' 121 | } 122 | ``` 123 | 124 | ## Development and deploy to jcenter 125 | 126 | rxbolts: 127 | 128 | ``` 129 | ./gradlew :rxbolts:build :rxbolts:bintrayUpload 130 | ``` 131 | 132 | ## See Also 133 | 134 | 135 | [![](https://raw.githubusercontent.com/yongjhih/RxParse/master/art/rxparse.png)](https://github.com/yongjhih/RxParse) 136 | 137 | * https://github.com/yongjhih/RxParse used 138 | 139 | ## ref. 140 | 141 | * https://github.com/BoltsFramework/Bolts-Android 142 | 143 | 144 | 145 | ## LICENSE 146 | 147 | Copyright 2015 8tory, Inc. 148 | 149 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 150 | 151 | http://www.apache.org/licenses/LICENSE-2.0 152 | 153 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 154 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2015 8tory, Inc. 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /art/rxbolts.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 28 | 33 | 39 | 43 | 48 | 54 | 55 | 56 | 74 | 76 | 77 | 79 | image/svg+xml 80 | 82 | 83 | 84 | 85 | 86 | 91 | 99 | Bolts 111 | 118 | 119 | 120 | --------------------------------------------------------------------------------