From 04c2889895483f5925c90ed7a856d38391fcab45 Mon Sep 17 00:00:00 2001 From: Isidro Henoch Date: Wed, 8 Dec 2021 04:28:51 -0600 Subject: WIP: Implements the basic structure for the units list/map - Updates the Devices and Positions APIs to properly construct the Url's query when there are null values - Adds a units controller to the shared module - Adds a devices and map fragment that each print the fetched units on the console - Adds a units view model to connect previously mentioned fragments with the units controller --- .../trackermap/TrackerMap/android/map/MapFragment.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'androidApp/src/main/java/mx/trackermap/TrackerMap/android/map') diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt index 0d4d91a..2ffaa2c 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt @@ -1,16 +1,22 @@ package mx.trackermap.TrackerMap.android.map import android.os.Bundle +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment +import kotlinx.coroutines.DelicateCoroutinesApi import mx.trackermap.TrackerMap.android.databinding.MapFragmentBinding +import mx.trackermap.TrackerMap.android.units.UnitsViewModel +import org.koin.androidx.viewmodel.ext.android.viewModel class MapFragment: Fragment() { private var _binding: MapFragmentBinding? = null private val binding get() = _binding!! + private val unitsViewModel: UnitsViewModel by viewModel() + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -24,4 +30,17 @@ class MapFragment: Fragment() { super.onDestroyView() _binding = null } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + setupObservers() + } + + @DelicateCoroutinesApi + private fun setupObservers() { + unitsViewModel.units.observe(this) { units -> + Log.d("MapFragment", "Success $units") + } + } } \ No newline at end of file -- cgit v1.2.3