diff --git a/CHANGELOG.md b/CHANGELOG.md index c56303fa450..e1c38f4f8a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 0.16.9 + +* `Versions`: + * `Koin`: `3.2.2` -> `3.3.2` + * `AppCompat`: `1.5.1` -> `1.6.0` +* `Ktor`: + * `Client` + * `HttpResponse.bodyOrNull` now retrieve callback to check if body should be received or null + * New extension `HttpResponse.bodyOrNullOnNoContent` + ## 0.16.8 * `Versions`: diff --git a/gradle.properties b/gradle.properties index ecd020b6e6a..99ba437f492 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,5 @@ crypto_js_version=4.1.1 # Project data group=dev.inmo -version=0.16.8 -android_code_version=176 +version=0.16.9 +android_code_version=177 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 51869c69f1c..eb4143623cc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,21 +17,21 @@ ktor = "2.2.3" gh-release = "2.4.1" -koin = "3.2.2" +koin = "3.3.2" android-gradle = "7.3.0" dexcount = "3.1.0" android-coreKtx = "1.9.0" android-recyclerView = "1.2.1" -android-appCompat = "1.5.1" +android-appCompat = "1.6.0" android-fragment = "1.5.5" android-espresso = "3.4.0" android-test = "1.1.3" android-props-minSdk = "21" android-props-compileSdk = "33" -android-props-buildTools = "33.0.0" +android-props-buildTools = "33.0.1" [libraries] diff --git a/koin/src/jvmMain/kotlin/FactoryWithBinds.kt b/koin/src/jvmMain/kotlin/FactoryWithBinds.kt index de91acff060..9b426bfe515 100644 --- a/koin/src/jvmMain/kotlin/FactoryWithBinds.kt +++ b/koin/src/jvmMain/kotlin/FactoryWithBinds.kt @@ -1,6 +1,7 @@ package dev.inmo.micro_utils.koin import org.koin.core.definition.Definition +import org.koin.core.definition.KoinDefinition import org.koin.core.instance.InstanceFactory import org.koin.core.module.Module import org.koin.core.qualifier.Qualifier @@ -13,7 +14,7 @@ inline fun Module.factoryWithBinds( qualifier: Qualifier? = null, bindFilter: (KClass<*>) -> Boolean = { true }, noinline definition: Definition -): Pair> { +): KoinDefinition<*> { return factory(qualifier, definition) binds (T::class.allSuperclasses.filter(bindFilter).toTypedArray()) } @@ -21,7 +22,7 @@ inline fun Module.factoryWithBinds( qualifier: String, bindFilter: (KClass<*>) -> Boolean = { true }, noinline definition: Definition -): Pair> { +): KoinDefinition<*> { return factory(qualifier, definition) binds (T::class.allSuperclasses.filter(bindFilter).toTypedArray()) } diff --git a/koin/src/jvmMain/kotlin/FactoryWithBindsAndRandomQualifier.kt b/koin/src/jvmMain/kotlin/FactoryWithBindsAndRandomQualifier.kt index 6231bec8b40..9ed1018af2d 100644 --- a/koin/src/jvmMain/kotlin/FactoryWithBindsAndRandomQualifier.kt +++ b/koin/src/jvmMain/kotlin/FactoryWithBindsAndRandomQualifier.kt @@ -1,6 +1,7 @@ package dev.inmo.micro_utils.koin import org.koin.core.definition.Definition +import org.koin.core.definition.KoinDefinition import org.koin.core.instance.InstanceFactory import org.koin.core.module.Module import kotlin.reflect.KClass @@ -8,6 +9,6 @@ import kotlin.reflect.KClass inline fun Module.factoryWithRandomQualifierAndBinds( bindFilter: (KClass<*>) -> Boolean = { true }, noinline definition: Definition -): Pair> { +): KoinDefinition<*> { return factoryWithBinds(RandomQualifier(), bindFilter, definition) } diff --git a/koin/src/jvmMain/kotlin/SignleWithBinds.kt b/koin/src/jvmMain/kotlin/SignleWithBinds.kt index 091ad6a8ca6..26c4577329f 100644 --- a/koin/src/jvmMain/kotlin/SignleWithBinds.kt +++ b/koin/src/jvmMain/kotlin/SignleWithBinds.kt @@ -1,6 +1,7 @@ package dev.inmo.micro_utils.koin import org.koin.core.definition.Definition +import org.koin.core.definition.KoinDefinition import org.koin.core.instance.InstanceFactory import org.koin.core.module.Module import org.koin.core.qualifier.Qualifier @@ -14,7 +15,7 @@ inline fun Module.singleWithBinds( createdAtStart: Boolean = false, bindFilter: (KClass<*>) -> Boolean = { true }, noinline definition: Definition -): Pair> { +): KoinDefinition<*> { return single(qualifier, createdAtStart, definition) binds (T::class.allSuperclasses.filter(bindFilter).toTypedArray()) } @@ -24,7 +25,7 @@ inline fun Module.singleWithBinds( createdAtStart: Boolean = false, bindFilter: (KClass<*>) -> Boolean = { true }, noinline definition: Definition -): Pair> { +): KoinDefinition<*> { return single(qualifier, createdAtStart, definition) binds (T::class.allSuperclasses.filter(bindFilter).toTypedArray()) } diff --git a/koin/src/jvmMain/kotlin/SingleWithBindsAndRandomQualifier.kt b/koin/src/jvmMain/kotlin/SingleWithBindsAndRandomQualifier.kt index 3839a1dd1c3..0e5d544b430 100644 --- a/koin/src/jvmMain/kotlin/SingleWithBindsAndRandomQualifier.kt +++ b/koin/src/jvmMain/kotlin/SingleWithBindsAndRandomQualifier.kt @@ -1,6 +1,7 @@ package dev.inmo.micro_utils.koin import org.koin.core.definition.Definition +import org.koin.core.definition.KoinDefinition import org.koin.core.instance.InstanceFactory import org.koin.core.module.Module import kotlin.reflect.KClass @@ -9,6 +10,6 @@ inline fun Module.singleWithRandomQualifierAndBinds( createdAtStart: Boolean = false, bindFilter: (KClass<*>) -> Boolean = { true }, noinline definition: Definition -): Pair> { +): KoinDefinition<*> { return singleWithBinds(RandomQualifier(), createdAtStart, bindFilter, definition) } diff --git a/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/BodyOrNull.kt b/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/BodyOrNull.kt index 55abf3b7c87..c3f2bedc83d 100644 --- a/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/BodyOrNull.kt +++ b/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/BodyOrNull.kt @@ -4,6 +4,10 @@ import io.ktor.client.call.body import io.ktor.client.statement.HttpResponse import io.ktor.http.HttpStatusCode -suspend inline fun HttpResponse.bodyOrNull() = takeIf { - status == HttpStatusCode.OK -} ?.body() +suspend inline fun HttpResponse.bodyOrNull( + statusFilter: (HttpResponse) -> Boolean = { it.status == HttpStatusCode.OK } +) = takeIf(statusFilter) ?.body() + +suspend inline fun HttpResponse.bodyOrNullOnNoContent() = bodyOrNull { + it.status != HttpStatusCode.NoContent +}