diff --git a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt index ea55bd810..a24ccc10a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt @@ -214,18 +214,21 @@ class EditProfileActivity : BaseActivity(), Injectable { } val onBackCallback = object : OnBackPressedCallback(enabled = true) { - override fun handleOnBackPressed() { - if (viewModel.hasUnsavedChanges(currentProfileData)) { - showUnsavedChangesDialog() - } else { - finish() - } - } + override fun handleOnBackPressed() = checkForUnsavedChanges() } onBackPressedDispatcher.addCallback(this, onBackCallback) } + fun checkForUnsavedChanges() { + if (viewModel.hasUnsavedChanges(currentProfileData)) { + showUnsavedChangesDialog() + } else { + finish() + } + } + + override fun onStop() { super.onStop() if (!isFinishing) {