From ee40584064ef2b1fa443f9894d35082b0d2be50d Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Thu, 3 Oct 2024 06:38:21 +0530 Subject: [PATCH] Keep Showing Progress Dialog on while Survey Loads (#2768) * added progress dialog support * flow changed to primitive * format fix --------- Co-authored-by: Gino Miceli <228050+gino-m@users.noreply.github.com> --- .../ground/ui/surveyselector/SurveySelectorFragment.kt | 8 ++++++-- .../ground/ui/surveyselector/SurveySelectorViewModel.kt | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorFragment.kt b/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorFragment.kt index 9a68a43878..ac4ef63671 100644 --- a/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorFragment.kt +++ b/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorFragment.kt @@ -55,11 +55,15 @@ class SurveySelectorFragment : AbstractFragment(), BackPressListener { showProgressDialog() } UiState.SurveyActivated -> { - dismissProgressDialog() + if (!viewModel.surveyActivationInProgress) { + dismissProgressDialog() + } } is UiState.SurveyListAvailable -> { handleSurveyListUpdated(uiState.surveys) - dismissProgressDialog() + if (!viewModel.surveyActivationInProgress) { + dismissProgressDialog() + } } is UiState.Error -> { dismissProgressDialog() diff --git a/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorViewModel.kt b/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorViewModel.kt index c145b638da..6ac07d7f6b 100644 --- a/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorViewModel.kt +++ b/ground/src/main/java/com/google/android/ground/ui/surveyselector/SurveySelectorViewModel.kt @@ -53,7 +53,8 @@ internal constructor( private val _uiState: MutableStateFlow = MutableStateFlow(UiState.FetchingSurveys) val uiState: StateFlow = _uiState.asStateFlow() - private var surveyActivationInProgress = false + + var surveyActivationInProgress = false init { viewModelScope.launch { @@ -86,8 +87,8 @@ internal constructor( } .fold( onSuccess = { - _uiState.emit(UiState.SurveyActivated) surveyActivationInProgress = false + _uiState.emit(UiState.SurveyActivated) navigateToHomeScreen() }, onFailure = { exception ->