Skip to content

Commit

Permalink
add timeline pin layout enum
Browse files Browse the repository at this point in the history
  • Loading branch information
crc-32 committed Jun 16, 2024
1 parent 2e591e0 commit e6a0abc
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TimelineItem(
itemId: Uuid,
parentId: Uuid, timestamp: UInt,
duration: UShort, type: Type,
flags: UShort, layout: UByte,
flags: UShort, layout: Layout,
attributes: List<Attribute>,
actions: List<Action>
) : StructMappable() {
Expand All @@ -23,12 +23,29 @@ class TimelineItem(

companion object {
fun fromValue(value: UByte): Type {
return values().firstOrNull { it.value == value }
return entries.firstOrNull { it.value == value }
?: error("Unknown timeline item type: $value")
}
}
}

enum class Layout(val value: UByte) {
GenericPin(1u),
CalendarPin(2u),
GenericReminder(3u),
GenericNotification(4u),
CommNotification(5u),
WeatherPin(6u),
SportsPin(7u);

companion object {
fun fromValue(value: UByte): Layout {
return entries.firstOrNull { it.value == value }
?: error("Unknown timeline item layout: $value")
}
}
}

val itemId = SUUID(m, itemId)
val parentId = SUUID(m, parentId)

Expand All @@ -52,7 +69,7 @@ class TimelineItem(
*/
val flags = SUShort(m, flags, endianness = '<')

val layout = SUByte(m, layout)
val layout = SUByte(m, layout.value)
val dataLength = SUShort(m, endianness = '<')
val attrCount = SUByte(m, attributes.size.toUByte())
val actionCount = SUByte(m, actions.size.toUByte())
Expand Down

0 comments on commit e6a0abc

Please sign in to comment.