aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt17
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt17
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt20
-rw-r--r--shared/build.gradle.kts1
4 files changed, 52 insertions, 3 deletions
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt
index cd8d7af..9d12608 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/commands/UnitCommandsFragment.kt
@@ -42,10 +42,21 @@ class UnitCommandsFragment: Fragment() {
super.onViewCreated(view, savedInstanceState)
binding.reportLoading.root.visibility = View.VISIBLE
- setupObservers()
setupEvents()
}
+ override fun onResume() {
+ super.onResume()
+
+ setupObservers()
+ }
+
+ override fun onStop() {
+ super.onStop()
+
+ removeObservers()
+ }
+
override fun onDestroyView() {
super.onDestroyView()
_binding = null
@@ -86,6 +97,10 @@ class UnitCommandsFragment: Fragment() {
unitCommandsViewModel.fetchCommands(id)
}
+ private fun removeObservers() {
+ unitCommandsViewModel.commands.removeObservers(viewLifecycleOwner)
+ }
+
private fun setupEvents() {
binding.commandsList.setOnItemClickListener { _, _, index, _ ->
Log.d("UnitCommandsFragment", "Selected item at index - $index")
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt
index ab94547..f046ccc 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/information/UnitInformationFragment.kt
@@ -47,10 +47,21 @@ class UnitInformationFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- setupObservers()
fetchInformation()
}
+ override fun onResume() {
+ super.onResume()
+
+ setupObservers()
+ }
+
+ override fun onStop() {
+ super.onStop()
+
+ removeObservers()
+ }
+
override fun onDestroyView() {
super.onDestroyView()
_binding = null
@@ -66,6 +77,10 @@ class UnitInformationFragment : Fragment() {
}
}
+ private fun removeObservers() {
+ unitInformationViewModel.unit.removeObservers(viewLifecycleOwner)
+ }
+
private fun fetchInformation() {
val id = arguments?.getInt(UnitDetailsAdapter.DEVICE_ID_ARG)
val name = arguments?.getString(UnitDetailsAdapter.DEVICE_NAME_ARG)
diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt
index d3e008f..600cfe1 100644
--- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt
+++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt
@@ -60,17 +60,29 @@ class UnitReportsFragment : Fragment() {
unitReportsViewModel.setDeviceId(
arguments?.getInt(UnitDetailsAdapter.DEVICE_ID_ARG) ?: 0)
- initializeMap()
setupEvents()
+ initializeMap()
+ }
+
+ override fun onResume() {
+ super.onResume()
+
setupObservers()
}
+ override fun onStop() {
+ super.onStop()
+
+ removeObservers()
+ }
+
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
private fun initializeMap() {
+ Log.d("UnitReportsFragment", "initializeMap()")
childFragmentManager.commit {
replace(R.id.reportsMapContainer, reportsMapFragment)
}
@@ -140,6 +152,11 @@ class UnitReportsFragment : Fragment() {
}
}
+ private fun removeObservers() {
+ unitReportsViewModel.report.removeObservers(viewLifecycleOwner)
+ unitReportsViewModel.reportPeriod.removeObservers(viewLifecycleOwner)
+ }
+
private fun showPeriodPopUp(view: View) {
val popOver = PopupMenu(context, view)
popOver.menuInflater.inflate(R.menu.report_period_options, popOver.menu)
@@ -262,6 +279,7 @@ class UnitReportsFragment : Fragment() {
}
private fun showMap(shouldShowMap: Boolean) {
+ Log.d("UnitReportsFragment", "showMap($shouldShowMap)")
binding.reportLoading.root.visibility = View.GONE
binding.eventsScroll.visibility = if (shouldShowMap) View.GONE else View.VISIBLE
binding.reportsMapContainer.visibility = if (shouldShowMap) View.VISIBLE else View.GONE
diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts
index 6853a0c..01fc192 100644
--- a/shared/build.gradle.kts
+++ b/shared/build.gradle.kts
@@ -75,5 +75,6 @@ android {
defaultConfig {
minSdk = 21
targetSdk = 31
+ ndk.abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64"))
}
} \ No newline at end of file