aboutsummaryrefslogtreecommitdiff
path: root/androidApp/src/main/java/mx/trackermap/TrackerMap/android/details
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-17 21:39:33 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-17 21:39:33 -0600
commitc3c57a26e62857434830c9b22bb4757edda2b202 (patch)
tree20b1cb3fed2353705b9a937568e3e231c57b83fa /androidApp/src/main/java/mx/trackermap/TrackerMap/android/details
parent07d184c408aba980f331ecaa3e4baef80b6ce82c (diff)
downloadetbsa-trackermap-mobile-c3c57a26e62857434830c9b22bb4757edda2b202.tar.gz
etbsa-trackermap-mobile-c3c57a26e62857434830c9b22bb4757edda2b202.tar.bz2
etbsa-trackermap-mobile-c3c57a26e62857434830c9b22bb4757edda2b202.zip
Refactored map fragment into wrapper with an overlay that contains zoom buttons
Diffstat (limited to 'androidApp/src/main/java/mx/trackermap/TrackerMap/android/details')
-rw-r--r--androidApp/src/main/java/mx/trackermap/TrackerMap/android/details/reports/UnitReportsFragment.kt64
1 files changed, 8 insertions, 56 deletions
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 e1a24ec..bceb113 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
@@ -22,6 +22,7 @@ import mx.trackermap.TrackerMap.android.R
import mx.trackermap.TrackerMap.android.databinding.UnitDetailsReportsBinding
import mx.trackermap.TrackerMap.android.details.UnitDetailsAdapter
import mx.trackermap.TrackerMap.android.map.MapFragment
+import mx.trackermap.TrackerMap.android.map.MapWrapperFragment
import mx.trackermap.TrackerMap.android.shared.MarkerTransformations
import mx.trackermap.TrackerMap.client.models.EventInformation
import mx.trackermap.TrackerMap.client.models.Geofence
@@ -43,7 +44,7 @@ class UnitReportsFragment : Fragment() {
private val binding get() = _binding!!
private val unitReportsViewModel: UnitReportsViewModel by viewModel()
- private lateinit var reportsMapFragment: MapFragment
+ private lateinit var reportsMapFragment: MapWrapperFragment
override fun onCreateView(
inflater: LayoutInflater,
@@ -87,7 +88,7 @@ class UnitReportsFragment : Fragment() {
private fun initializeMap() {
Log.d("UnitReportsFragment", "initializeMap()")
- reportsMapFragment = MapFragment()
+ reportsMapFragment = MapWrapperFragment()
childFragmentManager.commit {
replace(R.id.reportsMapContainer, reportsMapFragment)
}
@@ -127,8 +128,8 @@ class UnitReportsFragment : Fragment() {
when (report) {
is ReportController.Report.PositionsReport -> {
- display(report.positions)
- display(unitReportsViewModel.geofences.value!!)
+ reportsMapFragment.display(report.positions, isReport = true, center = true)
+ reportsMapFragment.display(unitReportsViewModel.geofences.value!!)
showMap(true)
}
is ReportController.Report.EventsReport -> {
@@ -136,8 +137,8 @@ class UnitReportsFragment : Fragment() {
showMap(false)
}
is ReportController.Report.StopsReport -> {
- display(report.stops)
- display(unitReportsViewModel.geofences.value!!)
+ reportsMapFragment.display(report.stops)
+ reportsMapFragment.display(unitReportsViewModel.geofences.value!!)
showMap(true)
}
is ReportController.Report.XlsxReport -> {
@@ -167,7 +168,7 @@ class UnitReportsFragment : Fragment() {
}
unitReportsViewModel.geofences.observe(viewLifecycleOwner) { geofences ->
- display(geofences)
+ reportsMapFragment.display(geofences)
}
}
@@ -199,25 +200,6 @@ class UnitReportsFragment : Fragment() {
popOver.show()
}
- private fun display(positions: Array<Position>) {
- if (reportsMapFragment.hasStarted) {
- Log.d("UnitReportsFragment", "Displaying positions: $positions")
-
- binding.eventsScroll.visibility = View.GONE
- binding.reportsMapContainer.visibility = View.VISIBLE
-
- reportsMapFragment.display(
- positions.mapNotNull(MarkerTransformations::positionToMarker).toTypedArray(),
- isReport = true
- )
- } else {
- reportsMapFragment.setupCallbacks.clear()
- reportsMapFragment.setupCallbacks.add {
- display(positions)
- }
- }
- }
-
private fun display(events: Array<EventInformation>) {
Log.d("UnitReportsFragment", "Displaying events: $events")
@@ -284,36 +266,6 @@ class UnitReportsFragment : Fragment() {
}
}
- private fun display(stops: Array<Stop>) {
- if (reportsMapFragment.hasStarted) {
- Log.d("UnitReportsFragment", "Displaying stops: $stops")
-
- binding.eventsScroll.visibility = View.GONE
- binding.reportsMapContainer.visibility = View.VISIBLE
-
- reportsMapFragment.display(
- stops.mapNotNull(MarkerTransformations::stopToMarker).toTypedArray(),
- isReport = true
- )
- } else {
- reportsMapFragment.setupCallbacks.add {
- display(stops)
- }
- }
- }
-
- private fun display(geofences: Array<Geofence>) {
- Log.d("UnitReportsFragment", "Geofences: $geofences")
- if (reportsMapFragment.hasStarted) {
- Log.d("UnitReportsFragment", "Displaying geofences: $geofences")
- reportsMapFragment.displayGeofences(geofences)
- } else {
- reportsMapFragment.setupCallbacks.add {
- display(geofences)
- }
- }
- }
-
private fun loading() {
binding.reportLoading.root.visibility = View.VISIBLE
binding.eventsScroll.visibility = View.GONE