Use Kotlinx Serialization with instances.

This commit is contained in:
Isira Seneviratne 2023-01-19 08:57:16 +05:30
parent f98123270e
commit 4876068c54
2 changed files with 13 additions and 12 deletions

View File

@ -1,15 +1,16 @@
package com.github.libretube.api.obj package com.github.libretube.api.obj
import com.fasterxml.jackson.annotation.JsonIgnoreProperties import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@JsonIgnoreProperties(ignoreUnknown = true) @Serializable
data class Instances( data class Instances(
var name: String? = null, val name: String,
var api_url: String? = null, @SerialName("api_url") val apiUrl: String,
var locations: String? = null, val locations: String,
var version: String? = null, val version: String,
var up_to_date: Boolean? = null, @SerialName("up_to_date") val upToDate: Boolean,
var cdn: Boolean? = null, val cdn: Boolean,
var registered: Long? = null, val registered: Long,
var last_checked: Long? = null @SerialName("last_checked") val lastChecked: Long
) )

View File

@ -137,8 +137,8 @@ class InstanceSettings : BasePreferenceFragment() {
response?.sortBy { it.name } response?.sortBy { it.name }
instanceNames.addAll(response.orEmpty().map { it.name ?: "" }) instanceNames.addAll(response.orEmpty().map { it.name })
instanceValues.addAll(response.orEmpty().map { it.api_url ?: "" }) instanceValues.addAll(response.orEmpty().map { it.apiUrl })
customInstances.forEach { instance -> customInstances.forEach { instance ->
instanceNames += instance.name instanceNames += instance.name