State to IntArray mapper
This commit is contained in:
parent
2b0746f6c4
commit
ff2e163983
4 changed files with 173 additions and 32 deletions
96
app/src/main/java/eu/ztsh/garmin/data/Model.kt
Normal file
96
app/src/main/java/eu/ztsh/garmin/data/Model.kt
Normal file
|
@ -0,0 +1,96 @@
|
|||
package eu.ztsh.garmin.data
|
||||
|
||||
enum class OutType(val value: Int) {
|
||||
|
||||
Off(0x00),
|
||||
Lane(0x01),
|
||||
LongerLane(0x02),
|
||||
LeftRoundabout(0x04),
|
||||
RightRoundabout(0x08),
|
||||
Flag(0x40),
|
||||
ArrowOnly(0x80);
|
||||
|
||||
}
|
||||
|
||||
|
||||
enum class OutAngle(val value: Int) {
|
||||
|
||||
Down(0x01),
|
||||
SharpRight(0x02),
|
||||
Right(0x04),
|
||||
EasyRight(0x08),
|
||||
Straight(0x10),
|
||||
EasyLeft(0x20),
|
||||
Left(0x40),
|
||||
SharpLeft(0x80),
|
||||
LeftDown(0x81),
|
||||
RightDown(0x82),
|
||||
AsDirection(0x00)
|
||||
|
||||
}
|
||||
|
||||
enum class Unit(val value: Int) {
|
||||
|
||||
Any(0),
|
||||
Metres(1),
|
||||
Kilometres(3),
|
||||
Miles(5),
|
||||
Foot(8)
|
||||
|
||||
}
|
||||
|
||||
enum class Lane(val value: Int) {
|
||||
|
||||
DotsRight(0x01),
|
||||
OuterRight(0x02),
|
||||
MiddleRight(0x04),
|
||||
InnerRight(0x08),
|
||||
InnerLeft(0x10),
|
||||
MiddleLeft(0x20),
|
||||
OuterLeft(0x40),
|
||||
DotsLeft(0x80)
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
class Direction {
|
||||
var angle: OutAngle = OutAngle.AsDirection
|
||||
var out: OutType = OutType.Lane
|
||||
var roundabout: OutAngle = OutAngle.AsDirection
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Direction
|
||||
|
||||
if (angle != other.angle) return false
|
||||
if (out != other.out) return false
|
||||
if (roundabout != other.roundabout) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = angle.hashCode()
|
||||
result = 31 * result + out.hashCode()
|
||||
result = 31 * result + roundabout.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue