From abad322fd50b21fb102ddd539ace6fcc0f8ff2b4 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 +++++++++++ androidApp/src/main/res/drawable/ic_baseline_list_24.xml | 10 ++++++++++ androidApp/src/main/res/drawable/ic_baseline_map_24.xml | 10 ++++++++++ 3 files changed, 31 insertions(+) create mode 100644 androidApp/src/main/res/drawable/ic_baseline_list_24.xml create mode 100644 androidApp/src/main/res/drawable/ic_baseline_map_24.xml 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) diff --git a/androidApp/src/main/res/drawable/ic_baseline_list_24.xml b/androidApp/src/main/res/drawable/ic_baseline_list_24.xml new file mode 100644 index 0000000..b0e68e0 --- /dev/null +++ b/androidApp/src/main/res/drawable/ic_baseline_list_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/androidApp/src/main/res/drawable/ic_baseline_map_24.xml b/androidApp/src/main/res/drawable/ic_baseline_map_24.xml new file mode 100644 index 0000000..d1274d8 --- /dev/null +++ b/androidApp/src/main/res/drawable/ic_baseline_map_24.xml @@ -0,0 +1,10 @@ + + + -- cgit v1.2.3