aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-29 04:24:01 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-29 04:24:01 -0600
commit65ea295e0c013d143552988911d44a84876f4f30 (patch)
treec4c19d9ade5783ea401af399740f5e3411617383
parente1d8854d7d5e789ed84e8948f17fb0dac0d44da6 (diff)
downloadetbsa-trackermap-mobile-65ea295e0c013d143552988911d44a84876f4f30.tar.gz
etbsa-trackermap-mobile-65ea295e0c013d143552988911d44a84876f4f30.tar.bz2
etbsa-trackermap-mobile-65ea295e0c013d143552988911d44a84876f4f30.zip
Updated UnitRenderData with new getStatus() and getEngineStop() functions in UnitInformation
-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 ->