aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices
diff options
context:
space:
mode:
authorIsidro Henoch <imhenoch@protonmail.com>2022-01-12 18:05:18 -0600
committerIsidro Henoch <imhenoch@protonmail.com>2022-01-12 18:05:18 -0600
commit88972a0e0d42c355fbed65d7ada3bcbdaad76287 (patch)
tree5f079f972dc53162445ac6a1a5f63d397431e4a2 /androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices
parent9424b6b94d36f0f538576399b949884f6db29ac2 (diff)
downloadetbsa-trackermap-mobile-88972a0e0d42c355fbed65d7ada3bcbdaad76287.tar.gz
etbsa-trackermap-mobile-88972a0e0d42c355fbed65d7ada3bcbdaad76287.tar.bz2
etbsa-trackermap-mobile-88972a0e0d42c355fbed65d7ada3bcbdaad76287.zip
Fixes issues
- Fixes the logout problem that don't let users sign in again - Fixes the search bug
Diffstat (limited to 'androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt21
1 files changed, 18 insertions, 3 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt
index bd3ab67..6bee413 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/devices/DevicesFragment.kt
@@ -11,18 +11,17 @@ import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.coroutines.DelicateCoroutinesApi
import mx.trackermap.TrackerMap.android.databinding.DevicesFragmentBinding
import mx.trackermap.TrackerMap.android.details.DetailsActivity
+import mx.trackermap.TrackerMap.android.units.UnitFragment
import mx.trackermap.TrackerMap.android.units.UnitsViewModel
import mx.trackermap.TrackerMap.client.models.UnitInformation
import org.koin.androidx.viewmodel.ext.android.viewModel
@DelicateCoroutinesApi
-class DevicesFragment : Fragment() {
+class DevicesFragment(private val unitsViewModel: UnitsViewModel) : UnitFragment(unitsViewModel) {
private var _binding: DevicesFragmentBinding? = null
private val binding get() = _binding!!
- private val unitsViewModel: UnitsViewModel by viewModel()
-
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@@ -42,9 +41,20 @@ class DevicesFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
setupList()
+ }
+
+ override fun onResume() {
+ super.onResume()
+
setupObservers()
}
+ override fun onPause() {
+ super.onPause()
+
+ removeObservers()
+ }
+
private fun setupList() {
binding.devicesList.layoutManager = LinearLayoutManager(
context, LinearLayoutManager.VERTICAL,
@@ -65,6 +75,11 @@ class DevicesFragment : Fragment() {
}
}
+ private fun removeObservers() {
+ Log.d("DevicesFragment", "removeObservers()")
+ unitsViewModel.units.removeObservers(viewLifecycleOwner)
+ }
+
private fun itemAction(unit: UnitInformation, action: Action) {
when (action) {
Action.DETAILS, Action.REPORTS, Action.COMMANDS -> {