From 323e94c3a3852c63ebe00e8448f3611b59b39b97 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Thu, 16 Dec 2021 03:21:32 -0600 Subject: Added icon for displayModeToggle according to displayMode --- .../mx/trackermap/TrackerMap/android/units/UnitsActivity.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'androidApp/src/main/java') 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) -- cgit v1.2.3