Skip to content

Commit

Permalink
Add a hideProgressCatching method to avoid crashing when showing prog…
Browse files Browse the repository at this point in the history
…ress

The same way we did it for showProgressCatching()
  • Loading branch information
LunarX committed Jun 27, 2024
1 parent c5576ed commit b8541f9
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import com.google.android.material.button.MaterialButton
import com.infomaniak.lib.core.utils.Utils
import com.infomaniak.lib.core.utils.hideProgress
import com.infomaniak.lib.core.utils.hideProgressCatching
import com.infomaniak.lib.core.utils.initProgress
import com.infomaniak.lib.core.utils.showProgressCatching
import com.infomaniak.mail.R
Expand All @@ -50,7 +50,7 @@ abstract class BaseAlertDialog(activityContext: Context) : DefaultLifecycleObser

fun resetLoadingAndDismiss() = with(alertDialog) {
if (isShowing) {
positiveButton.hideProgress(R.string.buttonCreate)
positiveButton.hideProgressCatching(R.string.buttonCreate)
negativeButton.isEnabled = true
setCancelable(true)
dismiss()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class LoginFragment : Fragment() {

private fun resetLoginButtons() = with(binding) {
connectButtonProgressTimer.cancel()
connectButton.hideProgress(RCore.string.connect)
connectButton.hideProgressCatching(RCore.string.connect)
signInButton.isEnabled = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class InvalidPasswordFragment : Fragment() {
passwordInputLayout.error = getString(error)
passwordInput.text = null
updatePasswordButtonProgressTimer.cancel()
confirmButton.hideProgress(R.string.buttonConfirm)
confirmButton.hideProgressCatching(R.string.buttonConfirm)
}

invalidPasswordViewModel.detachMailboxResult.observe(viewLifecycleOwner) { error ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class RestoreEmailsBottomSheetDialog : BottomSheetDialogFragment() {
val formattedDate = formattedDates?.get(date) ?: date
restoreEmailViewModel.restoreEmails(formattedDate).observe(viewLifecycleOwner) { apiResponse ->
restoreEmailsButtonProgressTimer.cancel()
binding.restoreMailsButton.hideProgress(R.string.buttonConfirmRestoreEmails)
binding.restoreMailsButton.hideProgressCatching(R.string.buttonConfirmRestoreEmails)
showSnackbar(if (apiResponse.isSuccess()) R.string.snackbarRestorationLaunched else apiResponse.translatedError)
findNavController().popBackStack()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class AttachMailboxFragment : Fragment() {

passwordInput.text = null
attachMailboxButtonProgressTimer.cancel()
attachMailboxButton.hideProgress(R.string.buttonAttachMailbox)
attachMailboxButton.hideProgressCatching(R.string.buttonAttachMailbox)
}
}

Expand Down

0 comments on commit b8541f9

Please sign in to comment.