From 6858de4bf2ba110abc29078194135d971ce71aa5 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Mon, 17 Jan 2022 00:58:01 -0600 Subject: If display mode is list, back button returns to map --- .../mx/trackermap/TrackerMap/android/units/UnitsActivity.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (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 d8ced28..e9b9010 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 @@ -153,9 +153,6 @@ class UnitsActivity : AppCompatActivity() { } supportFragmentManager.commit { replace(R.id.displayContainer, newFragment) - if (displayMode == UnitsViewModel.UnitsDisplayMode.LIST) { - addToBackStack(null) - } setTransition(TRANSIT_FRAGMENT_FADE) } } @@ -168,4 +165,12 @@ class UnitsActivity : AppCompatActivity() { unitsViewModel.unitsDisplayMode.removeObservers(this) unitsViewModel.selectedUnit.removeObservers(this) } + + override fun onBackPressed() { + if (unitsViewModel.unitsDisplayMode.value == UnitsViewModel.UnitsDisplayMode.LIST) { + unitsViewModel.setDisplayMode(UnitsViewModel.UnitsDisplayMode.MAP) + } else { + super.onBackPressed() + } + } } \ No newline at end of file -- cgit v1.2.3