aboutsummaryrefslogtreecommitdiff
path: root/androidApp
diff options
context:
space:
mode:
Diffstat (limited to 'androidApp')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/UnitRenderData.kt62
1 files changed, 30 insertions, 32 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/UnitRenderData.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/UnitRenderData.kt
index 123e1ab..7b66bd3 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/UnitRenderData.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/shared/UnitRenderData.kt
@@ -89,43 +89,41 @@ class UnitRenderData {
}
}
- statusIcon.visibility = View.GONE
- engineStopIcon.visibility = View.GONE
-
- unit.position?.let { position ->
- /* Status icon */
- statusIcon.visibility = View.VISIBLE
- position.speed?.let { speed ->
- if (speed >= 2) {
- statusIcon.setColorFilter(
- ContextCompat.getColor(context, R.color.colorOnline)
- )
- } else {
- statusIcon.setColorFilter(
- ContextCompat.getColor(context, R.color.colorOffline)
- )
- }
- } ?: run {
+ /* Status icon */
+ when (unit.getStatus()) {
+ UnitInformation.Status.ONLINE -> {
+ statusIcon.setColorFilter(
+ ContextCompat.getColor(context, R.color.colorOnline)
+ )
+ }
+ UnitInformation.Status.OFFLINE -> {
+ statusIcon.setColorFilter(
+ ContextCompat.getColor(context, R.color.colorOffline)
+ )
+ }
+ else -> {
statusIcon.setColorFilter(Color.GRAY)
}
+ }
- /* Engine stop */
- val attributes = position.attributes
- if (attributes["out1"].toString() != "null") {
+ /* Engine stop */
+ when(unit.getEngineStop()) {
+ UnitInformation.EngineStop.ON -> {
engineStopIcon.visibility = View.VISIBLE
- engineStopIcon.setImageResource(
- when (attributes["out1"].toString()) {
- "true" -> R.drawable.device_unlocked
- "false" -> R.drawable.device_locked
- else -> R.drawable.device_locked
- }
- )
- engineStopIcon.contentDescription = when (attributes["out1"].toString()) {
- "true" -> context.getString(R.string.unit_lock_on)
- "false" -> context.getString(R.string.unit_lock_off)
- else -> context.getString(R.string.unit_lock_on)
- }
+ engineStopIcon.setImageResource(R.drawable.device_unlocked)
+ engineStopIcon.contentDescription = context.getString(R.string.unit_lock_on)
+ }
+ UnitInformation.EngineStop.OFF -> {
+ engineStopIcon.visibility = View.VISIBLE
+ engineStopIcon.setImageResource(R.drawable.device_locked)
+ engineStopIcon.contentDescription = context.getString(R.string.unit_lock_off)
}
+ UnitInformation.EngineStop.UNKNOWN -> {
+ engineStopIcon.visibility = View.GONE
+ }
+ }
+
+ unit.position?.let { position ->
/* Speed */
position.speed?.let { speed ->