Skip to content

Commit

Permalink
migration to rx3.0, androidx, updated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
m7mdra committed Feb 10, 2022
1 parent 7eb18e3 commit a40a0ee
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 24 deletions.
23 changes: 12 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 {
Expand All @@ -29,7 +29,7 @@ android {
}

minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 31
}

sourceSets {
Expand All @@ -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'
}

Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=ashdavies
POM_DEVELOPER_NAME=Ash Davies

android.useAndroidX = true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void> {
override fun onComplete(task: Task<Void>) = try {
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/io/ashdavies/rx/rxtasks/CompletableTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void>.toCompletable(): Completable = asCompletable { addOnCompleteListener(CompletableEmitterListener(it)) }
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/io/ashdavies/rx/rxtasks/RxTasks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void>.toCompletable() instead",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T : Any>(private val emitter: SingleEmitter<T>) : OnCompleteListener<T> {
override fun onComplete(task: Task<T>) = try {
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/io/ashdavies/rx/rxtasks/SingleTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T : Any> Task<T>.toSingle(): Single<T> = asSingle { addOnCompleteListener(SingleEmitterListener(it)) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -15,7 +15,7 @@ internal class CompletableEmitterListenerTest {

@Test
fun `should represent result as completion`() {
listener.onComplete(Tasks.forResult<Void>(null))
listener.onComplete(Tasks.forResult(null))

then(emitter)
.should()
Expand All @@ -24,7 +24,7 @@ internal class CompletableEmitterListenerTest {

@Test
fun `should represent cancelled as error`() {
listener.onComplete(Tasks.forCanceled<Void>())
listener.onComplete(Tasks.forCanceled())

then(emitter)
.should()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a40a0ee

Please sign in to comment.