feat: added icons for cards
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package ru.omni_devel.cards
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import org.json.JSONArray
|
||||
|
||||
@Serializable
|
||||
class CardIcon(
|
||||
val names: LinkedHashMap<String, String>,
|
||||
val iconId: String? = null
|
||||
) {
|
||||
companion object {
|
||||
fun parseIconsDataFromJson(json: String): List<CardIcon> {
|
||||
val array = JSONArray(json)
|
||||
val icons = mutableListOf<CardIcon>()
|
||||
|
||||
for (i in 0 until array.length()) {
|
||||
val obj = array.getJSONObject(i)
|
||||
|
||||
icons.add(CardIcon(
|
||||
names = jsonObjectToMap(obj.getJSONObject("names")),
|
||||
iconId = if (obj.has("iconId")) obj.getString("iconId") else null
|
||||
))
|
||||
}
|
||||
|
||||
return icons
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user