diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-18 11:17:44 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-18 11:17:44 -0600 |
commit | 5472556161c2f781e7a0dabe48301f3b665641b1 (patch) | |
tree | 88e1f8811b4296c174b62fe91c695dbbab0926ea | |
parent | 269f3454d128237e82cbb57dac77c58ab7423aaf (diff) | |
download | etbsa-trackermap-mobile-5472556161c2f781e7a0dabe48301f3b665641b1.tar.gz etbsa-trackermap-mobile-5472556161c2f781e7a0dabe48301f3b665641b1.tar.bz2 etbsa-trackermap-mobile-5472556161c2f781e7a0dabe48301f3b665641b1.zip |
Show and hide fragments instead of replacing, so transition between map and list views is a lot faster
-rw-r--r-- | androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt | 14 |
1 files changed, 12 insertions, 2 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 9fcef7f..58147e4 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 @@ -66,6 +66,10 @@ class UnitsActivity : AppCompatActivity() { } private fun setupViews() { + supportFragmentManager.commit { + add(R.id.displayContainer, mapFragment) + add(R.id.displayContainer, devicesFragment) + } TooltipCompat.setTooltipText(binding.userButton, getString(R.string.open_profile)) TooltipCompat.setTooltipText(binding.mapLayerToggle, getString(R.string.switch_layer)) } @@ -148,9 +152,15 @@ class UnitsActivity : AppCompatActivity() { UnitsViewModel.UnitsDisplayMode.MAP -> mapFragment else -> mapFragment } + val oldFragment = + when (displayMode) { + UnitsViewModel.UnitsDisplayMode.LIST -> mapFragment + UnitsViewModel.UnitsDisplayMode.MAP -> devicesFragment + else -> devicesFragment + } supportFragmentManager.commit { - replace(R.id.displayContainer, newFragment) - setTransition(TRANSIT_FRAGMENT_FADE) + show(newFragment) + hide(oldFragment) } } unitsViewModel.selectedUnit.observe(this) { |