diff --git a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt index 2fa1d3ae7..2e7695aba 100644 --- a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt @@ -207,7 +207,7 @@ class EditProfileActivity : BaseActivity(), Injectable { val onBackCallback = object : OnBackPressedCallback(enabled = true) { override fun handleOnBackPressed() { - if (!viewModel.hasUnsavedChanges(gatherProfileData())) finish() + if (!viewModel.hasUnsavedChanges(profileData)) finish() lifecycleScope.launch { when (showConfirmationDialog()) { @@ -224,16 +224,17 @@ class EditProfileActivity : BaseActivity(), Injectable { override fun onStop() { super.onStop() if (!isFinishing) { - viewModel.updateProfile(gatherProfileData()) + viewModel.updateProfile(profileData) } } - private fun gatherProfileData() = ProfileData( - displayName = binding.displayNameEditText.text.toString(), - note = binding.noteEditText.text.toString(), - locked = binding.lockedCheckBox.isChecked, - fields = accountFieldEditAdapter.getFieldData() - ) + private val profileData + get() = ProfileData( + displayName = binding.displayNameEditText.text.toString(), + note = binding.noteEditText.text.toString(), + locked = binding.lockedCheckBox.isChecked, + fields = accountFieldEditAdapter.getFieldData()) + private fun observeImage( liveData: LiveData, @@ -308,7 +309,7 @@ class EditProfileActivity : BaseActivity(), Injectable { return super.onOptionsItemSelected(item) } - private fun save() = viewModel.save(gatherProfileData()) + private fun save() = viewModel.save(profileData) private fun onSaveFailure(msg: String?) { val errorMsg = msg ?: getString(R.string.error_media_upload_sending)