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
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@JsonIgnoreProperties(ignoreUnknown = true)
@Serializable
data class Instances(
var name: String? = null,
var api_url: String? = null,
var locations: String? = null,
var version: String? = null,
var up_to_date: Boolean? = null,
var cdn: Boolean? = null,
var registered: Long? = null,
var last_checked: Long? = null
val name: String,
@SerialName("api_url") val apiUrl: String,
val locations: String,
val version: String,
@SerialName("up_to_date") val upToDate: Boolean,
val cdn: Boolean,
val registered: Long,
@SerialName("last_checked") val lastChecked: Long
)

View File

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