Room tag: let the tag order be anything to avoid breaking at the moment.
This commit is contained in:
parent
9cc2cf8360
commit
ca890e1ef4
|
@ -21,5 +21,5 @@ import com.squareup.moshi.JsonClass
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class RoomTagContent(
|
data class RoomTagContent(
|
||||||
@Json(name = "tags") val tags: Map<String, Map<String, Double>> = emptyMap()
|
@Json(name = "tags") val tags: Map<String, Map<String, Any>> = emptyMap()
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,15 +32,16 @@ internal class RoomTagHandler {
|
||||||
val tags = ArrayList<RoomTagEntity>()
|
val tags = ArrayList<RoomTagEntity>()
|
||||||
for (tagName in content.tags.keys) {
|
for (tagName in content.tags.keys) {
|
||||||
val params = content.tags[tagName]
|
val params = content.tags[tagName]
|
||||||
val tag = if (params != null) {
|
val order = params?.get("order")
|
||||||
RoomTagEntity(tagName, params["order"])
|
val tag = if (order is Double) {
|
||||||
|
RoomTagEntity(tagName, order)
|
||||||
} else {
|
} else {
|
||||||
RoomTagEntity(tagName, null)
|
RoomTagEntity(tagName, null)
|
||||||
}
|
}
|
||||||
tags.add(tag)
|
tags.add(tag)
|
||||||
}
|
}
|
||||||
val roomSummaryEntity = RoomSummaryEntity.where(realm, roomId).findFirst()
|
val roomSummaryEntity = RoomSummaryEntity.where(realm, roomId).findFirst()
|
||||||
?: RoomSummaryEntity(roomId)
|
?: RoomSummaryEntity(roomId)
|
||||||
|
|
||||||
roomSummaryEntity.tags.clear()
|
roomSummaryEntity.tags.clear()
|
||||||
roomSummaryEntity.tags.addAll(tags)
|
roomSummaryEntity.tags.addAll(tags)
|
||||||
|
|
Loading…
Reference in New Issue