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
|
||||
-keepattributes SourceFile, LineNumberTable
|
||||
|
|
|
@ -13,11 +13,17 @@ import dev.msfjarvis.claw.model.LobstersPost
|
|||
import dev.msfjarvis.claw.model.LobstersPostDetails
|
||||
import dev.msfjarvis.claw.model.User
|
||||
import dev.msfjarvis.claw.util.TestUtils.getJson
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonNamingStrategy
|
||||
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
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 postDetails: LobstersPostDetails =
|
||||
json.decodeFromString(getJson("post_details_tdfoqh.json"))
|
||||
|
|
|
@ -14,14 +14,15 @@ import dagger.Provides
|
|||
import dagger.multibindings.IntoSet
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonNamingStrategy
|
||||
import okhttp3.MediaType
|
||||
import retrofit2.Converter
|
||||
|
||||
@Module
|
||||
@ContributesTo(ApplicationScope::class)
|
||||
object RetrofitModule {
|
||||
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
object RetrofitModule {
|
||||
|
||||
@Provides
|
||||
@IntoSet
|
||||
fun provideJsonConverterFactory(json: Json): Converter.Factory {
|
||||
|
@ -31,6 +32,9 @@ object RetrofitModule {
|
|||
|
||||
@Provides
|
||||
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"
|
||||
retrofit = "2.9.0"
|
||||
richtext = "0.16.0"
|
||||
serialization = "1.4.1"
|
||||
serialization = "1.5.0-RC"
|
||||
sqldelight = "2.0.0-alpha05"
|
||||
whetstone = "0.6.0-SNAPSHOT"
|
||||
workmanager = "2.8.0-rc01"
|
||||
|
|
|
@ -15,16 +15,12 @@ import kotlinx.serialization.Serializable
|
|||
|
||||
@Serializable
|
||||
class Comment(
|
||||
@SerialName("short_id") val shortId: String,
|
||||
val shortId: String,
|
||||
val comment: String,
|
||||
val url: String,
|
||||
val score: Int,
|
||||
@Serializable(with = JavaInstantSerializer::class)
|
||||
@SerialName("created_at")
|
||||
val createdAt: TemporalAccessor,
|
||||
@Serializable(with = JavaInstantSerializer::class)
|
||||
@SerialName("updated_at")
|
||||
val updatedAt: TemporalAccessor,
|
||||
@SerialName("indent_level") val indentLevel: Int,
|
||||
@Serializable(with = JavaInstantSerializer::class) val createdAt: TemporalAccessor,
|
||||
@Serializable(with = JavaInstantSerializer::class) val updatedAt: TemporalAccessor,
|
||||
val indentLevel: Int,
|
||||
@SerialName("commenting_user") val user: User,
|
||||
)
|
||||
|
|
|
@ -13,13 +13,13 @@ import kotlinx.serialization.Serializable
|
|||
|
||||
@Serializable
|
||||
class LobstersPost(
|
||||
@SerialName("short_id") val shortId: String,
|
||||
@SerialName("created_at") val createdAt: String,
|
||||
val shortId: String,
|
||||
val createdAt: String,
|
||||
val title: String,
|
||||
val url: String,
|
||||
val description: String,
|
||||
@SerialName("comment_count") val commentCount: Int,
|
||||
@SerialName("comments_url") val commentsUrl: String,
|
||||
val commentCount: Int,
|
||||
val commentsUrl: String,
|
||||
@SerialName("submitter_user") val submitter: User,
|
||||
val tags: List<String>,
|
||||
)
|
||||
|
|
|
@ -13,13 +13,13 @@ import kotlinx.serialization.Serializable
|
|||
|
||||
@Serializable
|
||||
class LobstersPostDetails(
|
||||
@SerialName("short_id") val shortId: String,
|
||||
@SerialName("created_at") val createdAt: String,
|
||||
val shortId: String,
|
||||
val createdAt: String,
|
||||
val title: String,
|
||||
val url: String,
|
||||
val description: String,
|
||||
@SerialName("comment_count") val commentCount: Int,
|
||||
@SerialName("comments_url") val commentsUrl: String,
|
||||
val commentCount: Int,
|
||||
val commentsUrl: String,
|
||||
@SerialName("submitter_user") val submitter: User,
|
||||
val tags: List<String>,
|
||||
val comments: List<Comment>,
|
||||
|
|
|
@ -16,6 +16,6 @@ class User(
|
|||
val username: String,
|
||||
val about: String,
|
||||
@SerialName("invited_by_user") val invitedBy: String?,
|
||||
@SerialName("avatar_url") val avatarUrl: String,
|
||||
@SerialName("created_at") val createdAt: String,
|
||||
val avatarUrl: String,
|
||||
val createdAt: String,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue