3486: Re-introduce separate check method to not need a synthetic accessor (lint error)

This commit is contained in:
Lakoja 2023-08-22 21:17:22 +02:00
parent ba50ff5686
commit 3a40274003
1 changed files with 10 additions and 7 deletions

View File

@ -214,18 +214,21 @@ class EditProfileActivity : BaseActivity(), Injectable {
} }
val onBackCallback = object : OnBackPressedCallback(enabled = true) { val onBackCallback = object : OnBackPressedCallback(enabled = true) {
override fun handleOnBackPressed() { override fun handleOnBackPressed() = checkForUnsavedChanges()
if (viewModel.hasUnsavedChanges(currentProfileData)) {
showUnsavedChangesDialog()
} else {
finish()
}
}
} }
onBackPressedDispatcher.addCallback(this, onBackCallback) onBackPressedDispatcher.addCallback(this, onBackCallback)
} }
fun checkForUnsavedChanges() {
if (viewModel.hasUnsavedChanges(currentProfileData)) {
showUnsavedChangesDialog()
} else {
finish()
}
}
override fun onStop() { override fun onStop() {
super.onStop() super.onStop()
if (!isFinishing) { if (!isFinishing) {