From a6a95167dbfe48fa0c5d6b61219309d346142979 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Sat, 9 Apr 2022 00:02:03 -0500 Subject: - [shared] Rewrote ReportDates to allow for custom date period. - [android] Rewrote report handling to use new ReportPeriod. - [ios] Not rewritten yet, it won't build! --- .../details/information/UnitInformationFragment.kt | 2 +- .../android/details/reports/UnitReportsFragment.kt | 34 ++++++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'androidApp/src/main/java') 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 e731587..fb0a0bc 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 @@ -115,7 +115,7 @@ class UnitInformationFragment : Fragment() { } private fun displayInformation(unit: UnitInformation) { - val context = context!! + val context = requireContext() val details: MutableList> = mutableListOf() unit.device.contact?.let { contact -> details.add(getString(R.string.unit_info_contact) to contact) 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 60ad531..091cb7b 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 @@ -137,7 +137,7 @@ class UnitReportsFragment : Fragment() { exportAction = UnitReportsViewModel.ExportAction.ACTION_SHARE unitReportsViewModel.fetchReportXlsx() } - unitReportsViewModel.setReportPeriod(ReportDates.ReportPeriod.TODAY) + unitReportsViewModel.setReportPeriod(ReportDates.ReportPeriod.Today()) unitReportsViewModel.setReportType(ReportController.ReportType.POSITIONS) } @@ -181,13 +181,14 @@ class UnitReportsFragment : Fragment() { binding.periodButton.text = context?.getString( when (period) { - ReportDates.ReportPeriod.TODAY -> R.string.period_today - ReportDates.ReportPeriod.LAST_24 -> R.string.period_last_24 - ReportDates.ReportPeriod.YESTERDAY -> R.string.period_yesterday - ReportDates.ReportPeriod.THIS_WEEK -> R.string.period_this_week - ReportDates.ReportPeriod.LAST_7 -> R.string.period_last_7 - ReportDates.ReportPeriod.THIS_MONTH -> R.string.period_this_month - ReportDates.ReportPeriod.LAST_30 -> R.string.period_last_30 + is ReportDates.ReportPeriod.Today -> R.string.period_today + is ReportDates.ReportPeriod.Last24 -> R.string.period_last_24 + is ReportDates.ReportPeriod.Yesterday -> R.string.period_yesterday + is ReportDates.ReportPeriod.ThisWeek -> R.string.period_this_week + is ReportDates.ReportPeriod.Last7 -> R.string.period_last_7 + is ReportDates.ReportPeriod.ThisMonth -> R.string.period_this_month + is ReportDates.ReportPeriod.Last30 -> R.string.period_last_30 + is ReportDates.ReportPeriod.Custom -> R.string.period_custom } ) } @@ -210,14 +211,15 @@ class UnitReportsFragment : Fragment() { popOver.setOnMenuItemClickListener { item -> unitReportsViewModel.setReportPeriod( when (item.itemId) { - R.id.optionToday -> ReportDates.ReportPeriod.TODAY - R.id.optionLast24 -> ReportDates.ReportPeriod.LAST_24 - R.id.optionYesterday -> ReportDates.ReportPeriod.YESTERDAY - R.id.optionWeek -> ReportDates.ReportPeriod.THIS_WEEK - R.id.optionLast7 -> ReportDates.ReportPeriod.LAST_7 - R.id.optionMonth -> ReportDates.ReportPeriod.THIS_MONTH - R.id.optionLast30 -> ReportDates.ReportPeriod.LAST_30 - else -> ReportDates.ReportPeriod.TODAY + R.id.optionToday -> ReportDates.ReportPeriod.Today() + R.id.optionLast24 -> ReportDates.ReportPeriod.Last24() + R.id.optionYesterday -> ReportDates.ReportPeriod.Yesterday() + R.id.optionWeek -> ReportDates.ReportPeriod.ThisWeek() + R.id.optionLast7 -> ReportDates.ReportPeriod.Last7() + R.id.optionMonth -> ReportDates.ReportPeriod.ThisMonth() + R.id.optionLast30 -> ReportDates.ReportPeriod.Last30() + R.id.optionCustom -> ReportDates.ReportPeriod.Custom() + else -> ReportDates.ReportPeriod.Today() } ) true -- cgit v1.2.3