Data cache

This commit is contained in:
Piotr Dec 2023-08-25 08:25:06 +02:00
parent 89e16fb805
commit b5cc580cf8
No known key found for this signature in database
GPG key ID: ABD6CB83D6110D27
5 changed files with 178 additions and 40 deletions

View file

@ -52,20 +52,64 @@ enum class Lane(val value: Int) {
}
open class Arrows(val lanes: List<Lane>) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as Arrows
return lanes == other.lanes
}
override fun hashCode(): Int {
return lanes.hashCode()
}
}
class Lanes(lanes: List<Lane>) : Arrows(lanes)
class Outlines(lanes: List<Lane>) : Arrows(lanes)
class Distance(val distance: Int, val unit: Unit) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as Distance
if (distance != other.distance) return false
if (unit != other.unit) return false
return true
}
override fun hashCode(): Int {
var result = distance
result = 31 * result + unit.hashCode()
return result
}
}
class Speed(val speed: Int, val limit: Int)
class Arrival(val hours: Int, val minutes: Int)
class State {
var lineArrows: List<Lane> = listOf()
var lineOutlines: List<Lane> = listOf()
var direction = Direction()
var distance: Int = 0
var unit: Unit = Unit.Any
var speed: Int = 0
var limit: Int = 0
var hours: Int = 0
var minutes: Int = 0
var traffic: Boolean = false
var flag: Boolean = false
var control: Boolean = false
var lineArrows: Lanes? = null
var lineOutlines: Outlines? = null
var direction : Direction? = null
var distance: Distance? = null
var speed: Speed? = null
var arrival: Arrival? = null
// TODO: support
var traffic: Boolean? = null
var flag: Boolean? = null
var control: Boolean? = null
}