diff options
Diffstat (limited to 'androidApp/src/main/java/mx/trackermap/TrackerMap/android/units')
-rw-r--r-- | androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitFragment.kt | 8 | ||||
-rw-r--r-- | androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitsActivity.kt | 11 |
2 files changed, 16 insertions, 3 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitFragment.kt new file mode 100644 index 0000000..ab3afc1 --- /dev/null +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/units/UnitFragment.kt @@ -0,0 +1,8 @@ +package mx.trackermap.TrackerMap.android.units + +import androidx.fragment.app.Fragment +import kotlinx.coroutines.DelicateCoroutinesApi + +open class UnitFragment @DelicateCoroutinesApi constructor( + private val unitsViewModel: UnitsViewModel +) : Fragment()
\ No newline at end of file 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 7e5f162..e198ce0 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 @@ -24,6 +24,12 @@ class UnitsActivity : AppCompatActivity() { private val binding get() = _binding!! private val unitsViewModel: UnitsViewModel by viewModel() + private val mapFragment: UnitMapFragment by lazy { + UnitMapFragment(unitsViewModel) + } + private val devicesFragment: DevicesFragment by lazy { + DevicesFragment(unitsViewModel) + } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -73,9 +79,8 @@ class UnitsActivity : AppCompatActivity() { val newFragment = when (displayMode) { - UnitsViewModel.UnitsDisplayMode.LIST -> DevicesFragment() - UnitsViewModel.UnitsDisplayMode.MAP -> UnitMapFragment() - else -> DevicesFragment() + UnitsViewModel.UnitsDisplayMode.LIST -> devicesFragment + UnitsViewModel.UnitsDisplayMode.MAP -> mapFragment } supportFragmentManager.commit { replace(R.id.displayContainer, newFragment) |