From 3bd4a7a2451c2c0af96e4b9814406fec8e020319 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 12 Aug 2024 23:09:38 +0600 Subject: [PATCH 1/5] start 2.4.0 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fda6290..36209b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 2.4.0 + ## 2.3.0 * `doWhile` now will guarantee that it will not call `doOnce` more than once for time diff --git a/gradle.properties b/gradle.properties index fef0e73..2fb2c87 100644 --- a/gradle.properties +++ b/gradle.properties @@ -36,5 +36,5 @@ androidx_work_version=2.9.0 ## Common -version=2.3.0 -android_code_version=40 +version=2.4.0 +android_code_version=41 From 3845f6e0c5d8f27d9cbee854b7dc8681d7025b74 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 12 Aug 2024 23:21:57 +0600 Subject: [PATCH 2/5] update dependencies --- .gitignore | 1 + CHANGELOG.md | 7 +++++++ gradle.properties | 14 +++++++------- src/androidMain/kotlin/KronSchedulerWork.kt | 9 ++++++--- src/androidMain/kotlin/ResultChecker.kt | 10 ++++++++++ 5 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 src/androidMain/kotlin/ResultChecker.kt diff --git a/.gitignore b/.gitignore index 7695475..e9dc09e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea +.kotlin out/* *.iml target diff --git a/CHANGELOG.md b/CHANGELOG.md index 36209b2..0835d70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## 2.4.0 +* `Version`: + * `Kotlin`: `2.0.10` + * `Coroutines`: `1.8.1` + * `Serialization`: `1.7.1` + * `Klock`: `5.4.0` + * `AndroidXWork`: `2.9.1` + ## 2.3.0 * `doWhile` now will guarantee that it will not call `doOnce` more than once for time diff --git a/gradle.properties b/gradle.properties index 2fb2c87..d0a9854 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,9 +9,9 @@ android.useAndroidX=true android.enableJetifier=false -kotlin_version=1.9.23 -kotlin_coroutines_version=1.8.0 -kotlin_serialization_version=1.6.3 +kotlin_version=2.0.10 +kotlin_coroutines_version=1.8.1 +kotlin_serialization_version=1.7.1 dokka_version=1.9.20 @@ -23,16 +23,16 @@ github_release_plugin_version=2.5.2 ## Android -android_gradle_version=8.1.4 +android_gradle_version=8.2.2 android_minSdkVersion=21 -android_compileSdkVersion=34 -android_buildToolsVersion=34.0.0 +android_compileSdkVersion=35 +android_buildToolsVersion=35.0.0 dexcount_version=4.0.0 junit_version=4.12 test_ext_junit_version=1.1.3 espresso_core=3.4.0 -androidx_work_version=2.9.0 +androidx_work_version=2.9.1 ## Common diff --git a/src/androidMain/kotlin/KronSchedulerWork.kt b/src/androidMain/kotlin/KronSchedulerWork.kt index 09567e9..17c5b14 100644 --- a/src/androidMain/kotlin/KronSchedulerWork.kt +++ b/src/androidMain/kotlin/KronSchedulerWork.kt @@ -139,9 +139,12 @@ abstract class KronSchedulerWork( } throw e } - when (result) { - is Result.Failure -> if (prolongOnFailure) prolong() - is Result.Success -> if (prolongOnSuccess) prolong() + result.outputData + if (result.isSuccess()) { + if (prolongOnSuccess) prolong() + } + if (result.isFailure()) { + if (prolongOnFailure) prolong() } return result } diff --git a/src/androidMain/kotlin/ResultChecker.kt b/src/androidMain/kotlin/ResultChecker.kt new file mode 100644 index 0000000..5ed48ff --- /dev/null +++ b/src/androidMain/kotlin/ResultChecker.kt @@ -0,0 +1,10 @@ +package dev.inmo.krontab + +import android.annotation.SuppressLint +import androidx.work.ListenableWorker + +@SuppressLint("RestrictedApi") +internal fun ListenableWorker.Result.isSuccess() = this is ListenableWorker.Result.Success + +@SuppressLint("RestrictedApi") +internal fun ListenableWorker.Result.isFailure() = this is ListenableWorker.Result.Failure From 552ec14d66f148bec6de1113541e9da9ae772dd2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 12 Aug 2024 23:25:23 +0600 Subject: [PATCH 3/5] update result checker in KronSchedulerWork --- src/androidMain/kotlin/KronSchedulerWork.kt | 15 ++++++++------- src/androidMain/kotlin/ResultChecker.kt | 11 +++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/androidMain/kotlin/KronSchedulerWork.kt b/src/androidMain/kotlin/KronSchedulerWork.kt index 17c5b14..f0afd98 100644 --- a/src/androidMain/kotlin/KronSchedulerWork.kt +++ b/src/androidMain/kotlin/KronSchedulerWork.kt @@ -139,13 +139,14 @@ abstract class KronSchedulerWork( } throw e } - result.outputData - if (result.isSuccess()) { - if (prolongOnSuccess) prolong() - } - if (result.isFailure()) { - if (prolongOnFailure) prolong() - } + result.checkResults( + onFailure = { + if (prolongOnFailure) prolong() + }, + onSuccess = { + if (prolongOnSuccess) prolong() + } + ) return result } } diff --git a/src/androidMain/kotlin/ResultChecker.kt b/src/androidMain/kotlin/ResultChecker.kt index 5ed48ff..eb57e3c 100644 --- a/src/androidMain/kotlin/ResultChecker.kt +++ b/src/androidMain/kotlin/ResultChecker.kt @@ -8,3 +8,14 @@ internal fun ListenableWorker.Result.isSuccess() = this is ListenableWorker.Resu @SuppressLint("RestrictedApi") internal fun ListenableWorker.Result.isFailure() = this is ListenableWorker.Result.Failure + +@SuppressLint("RestrictedApi") +internal inline fun ListenableWorker.Result.checkResults( + onFailure: () -> Unit, + onSuccess: () -> Unit +) { + when (this) { + is ListenableWorker.Result.Failure -> onFailure() + is ListenableWorker.Result.Success -> onSuccess() + } +} From 0c497f5dcbb45f66b59b71079379eb86ef870896 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 12 Aug 2024 23:32:04 +0600 Subject: [PATCH 4/5] update gradle wrapper --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e2c6241..95d3181 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-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip From 6e97a365e59ad91d0a5d820a30d79129a3f25a17 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 12 Aug 2024 23:40:30 +0600 Subject: [PATCH 5/5] remove redundant new functions --- src/androidMain/kotlin/ResultChecker.kt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/androidMain/kotlin/ResultChecker.kt b/src/androidMain/kotlin/ResultChecker.kt index eb57e3c..961becd 100644 --- a/src/androidMain/kotlin/ResultChecker.kt +++ b/src/androidMain/kotlin/ResultChecker.kt @@ -3,12 +3,6 @@ package dev.inmo.krontab import android.annotation.SuppressLint import androidx.work.ListenableWorker -@SuppressLint("RestrictedApi") -internal fun ListenableWorker.Result.isSuccess() = this is ListenableWorker.Result.Success - -@SuppressLint("RestrictedApi") -internal fun ListenableWorker.Result.isFailure() = this is ListenableWorker.Result.Failure - @SuppressLint("RestrictedApi") internal inline fun ListenableWorker.Result.checkResults( onFailure: () -> Unit,