From 3c76784b015c30238264d40768218cd610636459 Mon Sep 17 00:00:00 2001 From: Dmitry Borodin Date: Fri, 15 Sep 2017 14:57:54 +0200 Subject: [PATCH 1/3] library updated to coroutines 0.18 and compilation errors fixed --- build.gradle | 4 ++-- .../ru/gildor/coroutines/android/MainThreadDispatcher.kt | 4 ++-- .../main/kotlin/ru/gildor/coroutines/retrofit/CallAwait.kt | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index e588f16..a495bdc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.1.0-beta-38' - ext.kotlin_coroutines_version = '0.7-beta' + ext.kotlin_version = '1.1.4-3' + ext.kotlin_coroutines_version = '0.18' repositories { jcenter() maven { diff --git a/coroutines-android/src/main/kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt b/coroutines-android/src/main/kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt index cc637db..390341c 100644 --- a/coroutines-android/src/main/kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt +++ b/coroutines-android/src/main/kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt @@ -59,7 +59,7 @@ object MainThread : CoroutineDispatcher(), Delay { */ handler.postDelayed(runnable, unit.toMillis(time)) - continuation.onCompletion { handler.removeCallbacks(runnable) } + continuation.invokeOnCompletion { handler.removeCallbacks(runnable) } } } @@ -82,7 +82,7 @@ fun CoroutineLifecycle.mainAsync( val listener: () -> Unit = { job.cancel() } - job.onCompletion { removeListener(listener) } + job.invokeOnCompletion { removeListener(listener) } addListener(Destroy, listener) return job } diff --git a/coroutines-retrofit/src/main/kotlin/ru/gildor/coroutines/retrofit/CallAwait.kt b/coroutines-retrofit/src/main/kotlin/ru/gildor/coroutines/retrofit/CallAwait.kt index 457b5ee..abda47f 100644 --- a/coroutines-retrofit/src/main/kotlin/ru/gildor/coroutines/retrofit/CallAwait.kt +++ b/coroutines-retrofit/src/main/kotlin/ru/gildor/coroutines/retrofit/CallAwait.kt @@ -28,7 +28,6 @@ suspend fun Call.await(): T { continuation.resumeWithException(t) } }) - registerOnCompletion(continuation) } } @@ -58,7 +57,7 @@ suspend fun Call.awaitResult(): Result { } private fun Call<*>.registerOnCompletion(continuation: CancellableContinuation<*>) { - continuation.onCompletion { + continuation.invokeOnCompletion { if (continuation.isCancelled) try { cancel() From 0367fe8a2dd746264db425bbc4a70da37112dcd2 Mon Sep 17 00:00:00 2001 From: Dmitry Borodin Date: Fri, 15 Sep 2017 15:42:59 +0200 Subject: [PATCH 2/3] fixed runtime error - probably typo in check --- .../kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coroutines-android/src/main/kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt b/coroutines-android/src/main/kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt index 390341c..7fe196f 100644 --- a/coroutines-android/src/main/kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt +++ b/coroutines-android/src/main/kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt @@ -73,7 +73,7 @@ fun CoroutineLifecycle.mainAsync( context: CoroutineContext? = null, // Using EmptyCoroutineContext by default here will safe an `if` below block: suspend CoroutineScope.() -> Unit ): Job { - if (isEventSupported(cancelEvent)) { + if (!isEventSupported(cancelEvent)) { throw IllegalStateException("Cancel event $cancelEvent doesn't supported by CoroutineLifecycle $this") } val job = launch(if (context == null) MainThread else context + MainThread) { From 10c20e1b4f1c5c97a8188d012485014b1e9a3d94 Mon Sep 17 00:00:00 2001 From: Dmitry Borodin Date: Fri, 15 Sep 2017 15:59:09 +0200 Subject: [PATCH 3/3] android version updated --- build.gradle | 6 ------ coroutines-android/build.gradle | 14 +++++++------- coroutines-retrofit/build.gradle | 4 ++-- sample/build.gradle | 12 ++++++------ 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index a495bdc..6890036 100644 --- a/build.gradle +++ b/build.gradle @@ -5,9 +5,6 @@ buildscript { ext.kotlin_coroutines_version = '0.18' repositories { jcenter() - maven { - url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" - } } dependencies { classpath 'com.android.tools.build:gradle:2.2.2' @@ -18,9 +15,6 @@ buildscript { allprojects { repositories { jcenter() - maven { - url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" - } } } diff --git a/coroutines-android/build.gradle b/coroutines-android/build.gradle index 8a2d68b..eeb6c59 100644 --- a/coroutines-android/build.gradle +++ b/coroutines-android/build.gradle @@ -5,19 +5,19 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 26 + buildToolsVersion "26.0.1" defaultConfig { - minSdkVersion 9 - targetSdkVersion 25 + minSdkVersion 14 + targetSdkVersion 26 versionCode 1 versionName project.version testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } compileOptions { - targetCompatibility = '1.6' - sourceCompatibility = '1.6' + targetCompatibility = '1.7' + sourceCompatibility = '1.7' } sourceSets { @@ -29,7 +29,7 @@ android { dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" - compile 'com.android.support:appcompat-v7:25.1.1' + compile 'com.android.support:appcompat-v7:26.0.0-alpha1' testCompile 'junit:junit:4.12' } diff --git a/coroutines-retrofit/build.gradle b/coroutines-retrofit/build.gradle index 34d7e2c..42dcb7d 100644 --- a/coroutines-retrofit/build.gradle +++ b/coroutines-retrofit/build.gradle @@ -8,8 +8,8 @@ sourceSets { test.java.srcDirs += 'src/test/kotlin' } -targetCompatibility = '1.6' -sourceCompatibility = '1.6' +targetCompatibility = '1.7' +sourceCompatibility = '1.7' dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" diff --git a/sample/build.gradle b/sample/build.gradle index c665806..dfe0029 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -3,20 +3,20 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 25 - buildToolsVersion "25.0.1" + compileSdkVersion 26 + buildToolsVersion "26.0.1" defaultConfig { applicationId "ru.gildor.coroutines.android.sample" minSdkVersion 15 - targetSdkVersion 25 + targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } compileOptions { - targetCompatibility = '1.6' - sourceCompatibility = '1.6' + targetCompatibility = '1.7' + sourceCompatibility = '1.7' } sourceSets { @@ -26,7 +26,7 @@ android { } dependencies { - compile 'com.android.support:appcompat-v7:25.1.1' + compile 'com.android.support:appcompat-v7:26.0.0-alpha1' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" compile 'com.squareup.retrofit2:retrofit:2.1.0'