diff --git a/README.md b/README.md index 78dcb52..d975b9c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # Android RxTasks - [![](https://img.shields.io/circleci/project/github/ashdavies/rx-tasks.svg)](https://circleci.com/gh/ashdavies/rx-tasks) [![](https://img.shields.io/codacy/coverage/03ae86d9ce934421879bc407aa157732.svg)](https://app.codacy.com/project/ash.davies/rx-tasks/dashboard) [![](https://img.shields.io/maven-central/v/io.ashdavies.rx.rxtasks/rx-tasks.svg)](https://search.maven.org/artifact/io.ashdavies.rx.rxtasks/rx-tasks) @@ -8,8 +7,9 @@ [![](https://img.shields.io/codacy/grade/03ae86d9ce934421879bc407aa157732.svg)](https://app.codacy.com/project/ash.davies/rx-tasks/dashboard) [![](https://img.shields.io/github/last-commit/ashdavies/rx-tasks.svg)](https://github.com/ashdavies/rx-tasks/commits/master) [![](https://img.shields.io/github/issues-pr/ashdavies/rx-tasks.svg)](https://github.com/ashdavies/rx-tasks/pulls) +### This is a fork of https://github.com/ashdavies/rx-tasks that add support for rxjava3 -**Simple and lightweight RxJava2 conversion for the [Google Tasks APIs](https://developers.google.com/android/guides/tasks)** +**Simple and lightweight RxJava3 conversion for the [Google Tasks APIs](https://developers.google.com/android/guides/tasks)** ## The Tasks API > Starting with Google Play services version 9.0.0, you can use a `Task` API and a number of methods that return `Task` or its subclasses. `Task` is an API that represents asynchronous method calls, similar to `PendingResult` in previous versions of Google Play Services. diff --git a/build.gradle b/build.gradle index 0a74d21..a9f4c67 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,9 @@ buildscript { dependencies { - classpath 'com.android.tools.build:gradle:3.4.0-alpha07' + classpath "com.android.tools.build:gradle:7.0.4" classpath 'com.google.gms:google-services:4.2.0' classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1' - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.10' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0" } repositories { @@ -16,11 +16,11 @@ apply plugin: 'com.android.library' //apply plugin: 'jacoco-android' apply plugin: 'kotlin-android' -apply from: file('gradle/git-release-notes.gradle') -apply from: file('gradle/gradle-mvn-push.gradle') +//apply from: file('gradle/git-release-notes.gradle') +//apply from: file('gradle/gradle-mvn-push.gradle') android { - compileSdkVersion 28 + compileSdkVersion 31 defaultConfig { compileOptions { @@ -29,7 +29,7 @@ android { } minSdkVersion 14 - targetSdkVersion 28 + targetSdkVersion 31 } sourceSets { @@ -42,17 +42,18 @@ repositories { google() jcenter() } +ext.kotlin_version = "1.5.31" dependencies { - implementation 'com.google.android.gms:play-services-tasks:16.0.1' - implementation 'org.jetbrains.kotlin:kotlin-scripting-jvm:1.3.11' - implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.10' - implementation 'io.reactivex.rxjava2:rxjava:2.2.4' + implementation 'com.google.android.gms:play-services-tasks:18.0.1' + implementation 'org.jetbrains.kotlin:kotlin-scripting-jvm:1.6.10' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' testImplementation 'junit:junit:4.12' testImplementation 'com.google.truth:truth:0.34' - testImplementation 'org.mockito:mockito-core:2.23.0' + testImplementation 'org.mockito:mockito-core:4.0.0' testImplementation 'com.nhaarman:mockito-kotlin-kt1.1:1.6.0' } diff --git a/gradle.properties b/gradle.properties index 2d82975..4e83913 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,3 +16,5 @@ POM_LICENCE_DIST=repo POM_DEVELOPER_ID=ashdavies POM_DEVELOPER_NAME=Ash Davies + +android.useAndroidX = true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 689daac..76a73fd 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip diff --git a/src/main/kotlin/io/ashdavies/rx/rxtasks/CompletableEmitterListener.kt b/src/main/kotlin/io/ashdavies/rx/rxtasks/CompletableEmitterListener.kt index d81b001..5217de0 100644 --- a/src/main/kotlin/io/ashdavies/rx/rxtasks/CompletableEmitterListener.kt +++ b/src/main/kotlin/io/ashdavies/rx/rxtasks/CompletableEmitterListener.kt @@ -2,7 +2,7 @@ package io.ashdavies.rx.rxtasks import com.google.android.gms.tasks.OnCompleteListener import com.google.android.gms.tasks.Task -import io.reactivex.CompletableEmitter +import io.reactivex.rxjava3.core.CompletableEmitter internal class CompletableEmitterListener(private val emitter: CompletableEmitter) : OnCompleteListener { override fun onComplete(task: Task) = try { diff --git a/src/main/kotlin/io/ashdavies/rx/rxtasks/CompletableTask.kt b/src/main/kotlin/io/ashdavies/rx/rxtasks/CompletableTask.kt index 4b20e9d..ce7b0dd 100644 --- a/src/main/kotlin/io/ashdavies/rx/rxtasks/CompletableTask.kt +++ b/src/main/kotlin/io/ashdavies/rx/rxtasks/CompletableTask.kt @@ -2,8 +2,9 @@ package io.ashdavies.rx.rxtasks import android.app.Activity import com.google.android.gms.tasks.Task -import io.reactivex.Completable -import io.reactivex.CompletableEmitter +import io.reactivex.rxjava3.core.Completable +import io.reactivex.rxjava3.core.CompletableEmitter + import java.util.concurrent.Executor fun Task.toCompletable(): Completable = asCompletable { addOnCompleteListener(CompletableEmitterListener(it)) } diff --git a/src/main/kotlin/io/ashdavies/rx/rxtasks/RxTasks.kt b/src/main/kotlin/io/ashdavies/rx/rxtasks/RxTasks.kt index 43da2de..ae26d27 100644 --- a/src/main/kotlin/io/ashdavies/rx/rxtasks/RxTasks.kt +++ b/src/main/kotlin/io/ashdavies/rx/rxtasks/RxTasks.kt @@ -3,8 +3,9 @@ package io.ashdavies.rx.rxtasks import com.google.android.gms.tasks.Task -import io.reactivex.Completable -import io.reactivex.Single + +import io.reactivex.rxjava3.core.Completable +import io.reactivex.rxjava3.core.Single @Deprecated( message = "Use Task.toCompletable() instead", diff --git a/src/main/kotlin/io/ashdavies/rx/rxtasks/SingleEmitterListener.kt b/src/main/kotlin/io/ashdavies/rx/rxtasks/SingleEmitterListener.kt index a0d7ab3..c280707 100644 --- a/src/main/kotlin/io/ashdavies/rx/rxtasks/SingleEmitterListener.kt +++ b/src/main/kotlin/io/ashdavies/rx/rxtasks/SingleEmitterListener.kt @@ -2,7 +2,7 @@ package io.ashdavies.rx.rxtasks import com.google.android.gms.tasks.OnCompleteListener import com.google.android.gms.tasks.Task -import io.reactivex.SingleEmitter +import io.reactivex.rxjava3.core.SingleEmitter internal class SingleEmitterListener(private val emitter: SingleEmitter) : OnCompleteListener { override fun onComplete(task: Task) = try { diff --git a/src/main/kotlin/io/ashdavies/rx/rxtasks/SingleTask.kt b/src/main/kotlin/io/ashdavies/rx/rxtasks/SingleTask.kt index 6561c65..b3c7726 100644 --- a/src/main/kotlin/io/ashdavies/rx/rxtasks/SingleTask.kt +++ b/src/main/kotlin/io/ashdavies/rx/rxtasks/SingleTask.kt @@ -2,8 +2,9 @@ package io.ashdavies.rx.rxtasks import android.app.Activity import com.google.android.gms.tasks.Task -import io.reactivex.Single -import io.reactivex.SingleEmitter + +import io.reactivex.rxjava3.core.Single +import io.reactivex.rxjava3.core.SingleEmitter import java.util.concurrent.Executor fun Task.toSingle(): Single = asSingle { addOnCompleteListener(SingleEmitterListener(it)) } diff --git a/src/test/kotlin/io/ashdavies/rx/rxtasks/CompletableEmitterListenerTest.kt b/src/test/kotlin/io/ashdavies/rx/rxtasks/CompletableEmitterListenerTest.kt index 706d6be..78c4dcd 100644 --- a/src/test/kotlin/io/ashdavies/rx/rxtasks/CompletableEmitterListenerTest.kt +++ b/src/test/kotlin/io/ashdavies/rx/rxtasks/CompletableEmitterListenerTest.kt @@ -4,7 +4,7 @@ import com.google.android.gms.tasks.Tasks import com.nhaarman.mockito_kotlin.any import com.nhaarman.mockito_kotlin.mock import com.nhaarman.mockito_kotlin.then -import io.reactivex.CompletableEmitter +import io.reactivex.rxjava3.core.CompletableEmitter import org.junit.Test import java.util.concurrent.CancellationException @@ -15,7 +15,7 @@ internal class CompletableEmitterListenerTest { @Test fun `should represent result as completion`() { - listener.onComplete(Tasks.forResult(null)) + listener.onComplete(Tasks.forResult(null)) then(emitter) .should() @@ -24,7 +24,7 @@ internal class CompletableEmitterListenerTest { @Test fun `should represent cancelled as error`() { - listener.onComplete(Tasks.forCanceled()) + listener.onComplete(Tasks.forCanceled()) then(emitter) .should() diff --git a/src/test/kotlin/io/ashdavies/rx/rxtasks/SingleEmitterListenerTest.kt b/src/test/kotlin/io/ashdavies/rx/rxtasks/SingleEmitterListenerTest.kt index 840fcf0..fc80039 100644 --- a/src/test/kotlin/io/ashdavies/rx/rxtasks/SingleEmitterListenerTest.kt +++ b/src/test/kotlin/io/ashdavies/rx/rxtasks/SingleEmitterListenerTest.kt @@ -4,7 +4,7 @@ import com.google.android.gms.tasks.Tasks import com.nhaarman.mockito_kotlin.any import com.nhaarman.mockito_kotlin.mock import com.nhaarman.mockito_kotlin.then -import io.reactivex.SingleEmitter +import io.reactivex.rxjava3.core.SingleEmitter import org.junit.Test import java.util.concurrent.CancellationException