mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 08:17:04 +05:30
feat: upgrade kotlinx.serialization
to 1.5.0-RC
This commit is contained in:
parent
dea2d8b468
commit
540ea7ba43
8 changed files with 28 additions and 49 deletions
27
android/proguard-rules.pro
vendored
27
android/proguard-rules.pro
vendored
|
@ -1,29 +1,2 @@
|
||||||
# Keep `Companion` object fields of serializable classes.
|
|
||||||
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
|
|
||||||
-if @kotlinx.serialization.Serializable class **
|
|
||||||
-keepclassmembers class <1> {
|
|
||||||
static <1>$Companion Companion;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Keep `serializer()` on companion objects (both default and named) of serializable classes.
|
|
||||||
-if @kotlinx.serialization.Serializable class ** {
|
|
||||||
static **$* *;
|
|
||||||
}
|
|
||||||
-keepclassmembers class <2>$<3> {
|
|
||||||
kotlinx.serialization.KSerializer serializer(...);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Keep `INSTANCE.serializer()` of serializable objects.
|
|
||||||
-if @kotlinx.serialization.Serializable class ** {
|
|
||||||
public static ** INSTANCE;
|
|
||||||
}
|
|
||||||
-keepclassmembers class <1> {
|
|
||||||
public static <1> INSTANCE;
|
|
||||||
kotlinx.serialization.KSerializer serializer(...);
|
|
||||||
}
|
|
||||||
|
|
||||||
# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
|
|
||||||
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
|
|
||||||
|
|
||||||
-dontobfuscate
|
-dontobfuscate
|
||||||
-keepattributes SourceFile, LineNumberTable
|
-keepattributes SourceFile, LineNumberTable
|
||||||
|
|
|
@ -13,11 +13,17 @@ import dev.msfjarvis.claw.model.LobstersPost
|
||||||
import dev.msfjarvis.claw.model.LobstersPostDetails
|
import dev.msfjarvis.claw.model.LobstersPostDetails
|
||||||
import dev.msfjarvis.claw.model.User
|
import dev.msfjarvis.claw.model.User
|
||||||
import dev.msfjarvis.claw.util.TestUtils.getJson
|
import dev.msfjarvis.claw.util.TestUtils.getJson
|
||||||
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
import kotlinx.serialization.json.JsonNamingStrategy
|
||||||
|
|
||||||
|
@OptIn(ExperimentalSerializationApi::class)
|
||||||
class ApiWrapper(controller: EitherNetController<LobstersApi>) {
|
class ApiWrapper(controller: EitherNetController<LobstersApi>) {
|
||||||
private val json = Json { ignoreUnknownKeys = true }
|
private val json = Json {
|
||||||
|
ignoreUnknownKeys = true
|
||||||
|
namingStrategy = JsonNamingStrategy.SnakeCase
|
||||||
|
}
|
||||||
private val hottest: List<LobstersPost> = json.decodeFromString(getJson("hottest.json"))
|
private val hottest: List<LobstersPost> = json.decodeFromString(getJson("hottest.json"))
|
||||||
private val postDetails: LobstersPostDetails =
|
private val postDetails: LobstersPostDetails =
|
||||||
json.decodeFromString(getJson("post_details_tdfoqh.json"))
|
json.decodeFromString(getJson("post_details_tdfoqh.json"))
|
||||||
|
|
|
@ -14,14 +14,15 @@ import dagger.Provides
|
||||||
import dagger.multibindings.IntoSet
|
import dagger.multibindings.IntoSet
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
import kotlinx.serialization.json.JsonNamingStrategy
|
||||||
import okhttp3.MediaType
|
import okhttp3.MediaType
|
||||||
import retrofit2.Converter
|
import retrofit2.Converter
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@ContributesTo(ApplicationScope::class)
|
@ContributesTo(ApplicationScope::class)
|
||||||
|
@OptIn(ExperimentalSerializationApi::class)
|
||||||
object RetrofitModule {
|
object RetrofitModule {
|
||||||
|
|
||||||
@OptIn(ExperimentalSerializationApi::class)
|
|
||||||
@Provides
|
@Provides
|
||||||
@IntoSet
|
@IntoSet
|
||||||
fun provideJsonConverterFactory(json: Json): Converter.Factory {
|
fun provideJsonConverterFactory(json: Json): Converter.Factory {
|
||||||
|
@ -31,6 +32,9 @@ object RetrofitModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
fun provideJsonSerializer(): Json {
|
fun provideJsonSerializer(): Json {
|
||||||
return Json { ignoreUnknownKeys = true }
|
return Json {
|
||||||
|
ignoreUnknownKeys = true
|
||||||
|
namingStrategy = JsonNamingStrategy.SnakeCase
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ kotlin = "1.8.0"
|
||||||
okhttp = "3.14.9"
|
okhttp = "3.14.9"
|
||||||
retrofit = "2.9.0"
|
retrofit = "2.9.0"
|
||||||
richtext = "0.16.0"
|
richtext = "0.16.0"
|
||||||
serialization = "1.4.1"
|
serialization = "1.5.0-RC"
|
||||||
sqldelight = "2.0.0-alpha05"
|
sqldelight = "2.0.0-alpha05"
|
||||||
whetstone = "0.6.0-SNAPSHOT"
|
whetstone = "0.6.0-SNAPSHOT"
|
||||||
workmanager = "2.8.0-rc01"
|
workmanager = "2.8.0-rc01"
|
||||||
|
|
|
@ -15,16 +15,12 @@ import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class Comment(
|
class Comment(
|
||||||
@SerialName("short_id") val shortId: String,
|
val shortId: String,
|
||||||
val comment: String,
|
val comment: String,
|
||||||
val url: String,
|
val url: String,
|
||||||
val score: Int,
|
val score: Int,
|
||||||
@Serializable(with = JavaInstantSerializer::class)
|
@Serializable(with = JavaInstantSerializer::class) val createdAt: TemporalAccessor,
|
||||||
@SerialName("created_at")
|
@Serializable(with = JavaInstantSerializer::class) val updatedAt: TemporalAccessor,
|
||||||
val createdAt: TemporalAccessor,
|
val indentLevel: Int,
|
||||||
@Serializable(with = JavaInstantSerializer::class)
|
|
||||||
@SerialName("updated_at")
|
|
||||||
val updatedAt: TemporalAccessor,
|
|
||||||
@SerialName("indent_level") val indentLevel: Int,
|
|
||||||
@SerialName("commenting_user") val user: User,
|
@SerialName("commenting_user") val user: User,
|
||||||
)
|
)
|
||||||
|
|
|
@ -13,13 +13,13 @@ import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class LobstersPost(
|
class LobstersPost(
|
||||||
@SerialName("short_id") val shortId: String,
|
val shortId: String,
|
||||||
@SerialName("created_at") val createdAt: String,
|
val createdAt: String,
|
||||||
val title: String,
|
val title: String,
|
||||||
val url: String,
|
val url: String,
|
||||||
val description: String,
|
val description: String,
|
||||||
@SerialName("comment_count") val commentCount: Int,
|
val commentCount: Int,
|
||||||
@SerialName("comments_url") val commentsUrl: String,
|
val commentsUrl: String,
|
||||||
@SerialName("submitter_user") val submitter: User,
|
@SerialName("submitter_user") val submitter: User,
|
||||||
val tags: List<String>,
|
val tags: List<String>,
|
||||||
)
|
)
|
||||||
|
|
|
@ -13,13 +13,13 @@ import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class LobstersPostDetails(
|
class LobstersPostDetails(
|
||||||
@SerialName("short_id") val shortId: String,
|
val shortId: String,
|
||||||
@SerialName("created_at") val createdAt: String,
|
val createdAt: String,
|
||||||
val title: String,
|
val title: String,
|
||||||
val url: String,
|
val url: String,
|
||||||
val description: String,
|
val description: String,
|
||||||
@SerialName("comment_count") val commentCount: Int,
|
val commentCount: Int,
|
||||||
@SerialName("comments_url") val commentsUrl: String,
|
val commentsUrl: String,
|
||||||
@SerialName("submitter_user") val submitter: User,
|
@SerialName("submitter_user") val submitter: User,
|
||||||
val tags: List<String>,
|
val tags: List<String>,
|
||||||
val comments: List<Comment>,
|
val comments: List<Comment>,
|
||||||
|
|
|
@ -16,6 +16,6 @@ class User(
|
||||||
val username: String,
|
val username: String,
|
||||||
val about: String,
|
val about: String,
|
||||||
@SerialName("invited_by_user") val invitedBy: String?,
|
@SerialName("invited_by_user") val invitedBy: String?,
|
||||||
@SerialName("avatar_url") val avatarUrl: String,
|
val avatarUrl: String,
|
||||||
@SerialName("created_at") val createdAt: String,
|
val createdAt: String,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue