diff options
author | Iván Ávalos <avalos@disroot.org> | 2021-12-04 14:08:43 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2021-12-04 14:08:43 -0600 |
commit | b609ee1dc0ffe2a4c6acf2d08e13c46a7ded5fe1 (patch) | |
tree | fdec150435fe1bbeb9e8583864d442ea30861d31 /shared/src | |
parent | 0de7448f68def471cd34899f0012865103b0fb81 (diff) | |
download | etbsa-trackermap-mobile-b609ee1dc0ffe2a4c6acf2d08e13c46a7ded5fe1.tar.gz etbsa-trackermap-mobile-b609ee1dc0ffe2a4c6acf2d08e13c46a7ded5fe1.tar.bz2 etbsa-trackermap-mobile-b609ee1dc0ffe2a4c6acf2d08e13c46a7ded5fe1.zip |
Replaced Java stuff with Kotlin native stuff, and deleted ApplicationDelegates (probably useless)
Diffstat (limited to 'shared/src')
5 files changed, 8 insertions, 42 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt index 0f1d7da..c44d473 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt @@ -8,7 +8,6 @@ import io.ktor.client.request.* import io.ktor.client.statement.* import io.ktor.http.* import io.ktor.util.* -import java.io.File open class ApiClient(val baseUrl: String) { companion object { @@ -35,7 +34,6 @@ open class ApiClient(val baseUrl: String) { protected inline fun <reified T> fillRequest(requestBuilder: HttpRequestBuilder, content: T, mediaType: String = ApiJsonMediaType) { when { - content is File -> TODO("i don't know what to do here.") mediaType == ApiFormDataMediaType && content is Map<*, *> -> { val parametersBuilder = ParametersBuilder() content.forEach { map -> diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApplicationDelegates.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApplicationDelegates.kt deleted file mode 100644 index 7b91344..0000000 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApplicationDelegates.kt +++ /dev/null @@ -1,29 +0,0 @@ -package mx.trackermap.TrackerMap.client.infrastructure - -import kotlin.properties.ReadWriteProperty -import kotlin.reflect.KProperty - -object ApplicationDelegates { - /** - * Provides a property delegate, allowing the property to be set once and only once. - * - * If unset (no default value), a get on the property will throw [IllegalStateException]. - */ - fun <T> setOnce(defaultValue: T? = null): ReadWriteProperty<Any?, T> = SetOnce(defaultValue) - - private class SetOnce<T>(defaultValue: T? = null) : ReadWriteProperty<Any?, T> { - private var isSet = false - private var value: T? = defaultValue - - override fun getValue(thisRef: Any?, property: KProperty<*>): T { - return value ?: throw IllegalStateException("${property.name} not initialized") - } - - override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) = synchronized(this) { - if (!isSet) { - this.value = value - isSet = true - } - } - } -}
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/Errors.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/Errors.kt index 8932856..3c44140 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/Errors.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/Errors.kt @@ -1,8 +1,5 @@ -@file:Suppress("unused") package mx.trackermap.TrackerMap.client.infrastructure -import java.lang.RuntimeException - open class ClientException : RuntimeException { /** diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateAdapter.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateAdapter.kt index 6b73b60..7142665 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateAdapter.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateAdapter.kt @@ -1,14 +1,14 @@ package mx.trackermap.TrackerMap.client.infrastructure -import java.time.LocalDate -import java.time.format.DateTimeFormatter +import kotlinx.datetime.LocalDate + class LocalDateAdapter { fun toJson(value: LocalDate): String { - return DateTimeFormatter.ISO_LOCAL_DATE.format(value) + return value.toString() } fun fromJson(value: String): LocalDate { - return LocalDate.parse(value, DateTimeFormatter.ISO_LOCAL_DATE_TIME) + return LocalDate.parse(value) } }
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateTimeAdapter.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateTimeAdapter.kt index 1534448..d073ff4 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateTimeAdapter.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateTimeAdapter.kt @@ -1,15 +1,15 @@ package mx.trackermap.TrackerMap.client.infrastructure -import java.time.LocalDateTime -import java.time.format.DateTimeFormatter +import kotlinx.datetime.LocalDateTime + class LocalDateTimeAdapter { fun toJson(value: LocalDateTime): String { - return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(value) + return value.toString() } fun fromJson(value: String): LocalDateTime { - return LocalDateTime.parse(value, DateTimeFormatter.ISO_LOCAL_DATE_TIME) + return LocalDateTime.parse(value) } }
\ No newline at end of file |