From bea9813222089df26cc1b056be70ad1a5f793847 Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 14 Feb 2024 09:37:26 +0100 Subject: [PATCH] ktlint Signed-off-by: Pablo --- .../teiDashboard/DashboardRepositoryImpl.kt | 2 -- .../teiDashboard/DashboardViewModel.kt | 2 +- .../TeiDashboardMobileActivity.kt | 34 ++++++++++++------- .../teidata/TEIDataFragment.kt | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardRepositoryImpl.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardRepositoryImpl.kt index 4a3360a624..60beacb9eb 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardRepositoryImpl.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardRepositoryImpl.kt @@ -8,10 +8,8 @@ import io.reactivex.Single import io.reactivex.functions.Function import org.dhis2.bindings.profilePicturePath import org.dhis2.commons.data.tuples.Pair -import org.dhis2.commons.resources.ResourceManager import org.dhis2.commons.prefs.Preference import org.dhis2.commons.prefs.PreferenceProvider -import org.dhis2.utils.AuthorityException import org.dhis2.utils.DateUtils import org.dhis2.utils.ValueUtils import org.hisp.dhis.android.core.D2 diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardViewModel.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardViewModel.kt index 167e3f7e31..d31babce04 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardViewModel.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardViewModel.kt @@ -143,7 +143,7 @@ class DashboardViewModel( viewModelScope.launch(dispatcher.io()) { val result = async { dashboardModel.value.takeIf { it is DashboardEnrollmentModel }?.let { - repository.deleteEnrollmentIfPossible((it as DashboardEnrollmentModel).currentEnrollment.uid()) + repository.deleteEnrollment((it as DashboardEnrollmentModel).currentEnrollment.uid()) .blockingGet() } } diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/TeiDashboardMobileActivity.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/TeiDashboardMobileActivity.kt index 5df2fdf56b..f1f8619d61 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/TeiDashboardMobileActivity.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/TeiDashboardMobileActivity.kt @@ -553,7 +553,8 @@ class TeiDashboardMobileActivity : } val deleteEnrollmentItem = popupMenu.menu.findItem(R.id.deleteEnrollment) - deleteEnrollmentItem.isVisible = presenter.checkIfEnrollmentCanBeDeleted(enrollmentUid) + deleteEnrollmentItem.isVisible = + presenter.checkIfEnrollmentCanBeDeleted(enrollmentUid) if (enrollmentUid != null) { val status = presenter.getEnrollmentStatus(enrollmentUid) @@ -577,7 +578,7 @@ class TeiDashboardMobileActivity : showTutorial(true) } - R.id.markForFollowUp -> dashboardViewModel.onFollowUp(programModel) + R.id.markForFollowUp -> dashboardViewModel.onFollowUp() R.id.deleteTei -> showDeleteTEIConfirmationDialog() R.id.deleteEnrollment -> showRemoveEnrollmentConfirmationDialog() R.id.programSelector -> presenter.onEnrollmentSelectorClick() @@ -651,17 +652,24 @@ class TeiDashboardMobileActivity : } private fun showRemoveEnrollmentConfirmationDialog() { - DeleteBottomSheetDialog( - title = getString(R.string.remove_enrollment_dialog_title).format(programModel.currentProgram.displayName()), - description = getString(R.string.remove_enrollment_dialog_message).format(programModel.currentProgram.displayName()), - mainButtonText = getString(R.string.remove), - onMainButtonClick = { - presenter.deleteEnrollment() - }, - ).show( - supportFragmentManager, - DeleteBottomSheetDialog.TAG, - ) + val dashboardModel = dashboardViewModel.dashboardModel.value + if (dashboardModel is DashboardEnrollmentModel) { + DeleteBottomSheetDialog( + title = getString(R.string.remove_enrollment_dialog_title).format( + dashboardModel.currentProgram().displayName(), + ), + description = getString(R.string.remove_enrollment_dialog_message).format( + dashboardModel.currentProgram().displayName(), + ), + mainButtonText = getString(R.string.remove), + onMainButtonClick = { + dashboardViewModel.deleteEnrollment { authorityErrorMessage() } + }, + ).show( + supportFragmentManager, + DeleteBottomSheetDialog.TAG, + ) + } } override fun onRelationshipMapLoaded() { diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt index 9035c60142..1be6b3bee3 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt @@ -471,7 +471,7 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View { } override fun updateEnrollment(update: Boolean) { - if(update) { + if (update) { presenter.fetchEvents(update) presenter.getEnrollment()?.let { eventAdapter?.setEnrollment(it) } dashboardViewModel.updateDashboard()