aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt
diff options
context:
space:
mode:
Diffstat (limited to 'androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt11
1 files changed, 11 insertions, 0 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt
index 2be6da3..ea40d91 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt
@@ -5,12 +5,14 @@ import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.core.widget.doAfterTextChanged
import androidx.fragment.app.commit
+import kotlinx.coroutines.DelicateCoroutinesApi
import mx.trackermap.TrackerMap.android.R
import mx.trackermap.TrackerMap.android.databinding.UnitsActivityBinding
import mx.trackermap.TrackerMap.android.devices.DevicesFragment
import mx.trackermap.TrackerMap.android.map.MapFragment
import org.koin.androidx.viewmodel.ext.android.viewModel
+@DelicateCoroutinesApi
class UnitsActivity : AppCompatActivity() {
private var _binding: UnitsActivityBinding? = null
@@ -54,10 +56,19 @@ class UnitsActivity : AppCompatActivity() {
private fun setupObservers() {
unitsViewModel.unitsDisplayMode.observe(this) { displayMode ->
+ binding.displayModeToggle.setImageResource(
+ when (displayMode) {
+ UnitsViewModel.UnitsDisplayMode.LIST -> R.drawable.ic_baseline_map_24
+ UnitsViewModel.UnitsDisplayMode.MAP -> R.drawable.ic_baseline_list_24
+ else -> R.drawable.ic_baseline_map_24
+ }
+ )
+
val newFragment =
when (displayMode) {
UnitsViewModel.UnitsDisplayMode.LIST -> DevicesFragment()
UnitsViewModel.UnitsDisplayMode.MAP -> MapFragment()
+ else -> DevicesFragment()
}
supportFragmentManager.commit {
replace(R.id.displayContainer, newFragment)