From 634f020ffa9adae79f413c792ec9dcc3fb128a81 Mon Sep 17 00:00:00 2001 From: Martin Marconcini Date: Sat, 19 Aug 2023 17:57:25 +0200 Subject: [PATCH] Apply klint recommendations. --- .../com/keylesspalace/tusky/EditProfileActivity.kt | 4 ++-- .../tusky/viewmodel/EditProfileViewModel.kt | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt index b734d92a8..2fa1d3ae7 100644 --- a/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/EditProfileActivity.kt @@ -210,7 +210,7 @@ class EditProfileActivity : BaseActivity(), Injectable { if (!viewModel.hasUnsavedChanges(gatherProfileData())) finish() lifecycleScope.launch { - when(showConfirmationDialog()) { + when (showConfirmationDialog()) { AlertDialog.BUTTON_POSITIVE -> save() else -> finish() } @@ -232,7 +232,7 @@ class EditProfileActivity : BaseActivity(), Injectable { displayName = binding.displayNameEditText.text.toString(), note = binding.noteEditText.text.toString(), locked = binding.lockedCheckBox.isChecked, - fields = accountFieldEditAdapter.getFieldData(), + fields = accountFieldEditAdapter.getFieldData() ) private fun observeImage( diff --git a/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt index 46b16d5ed..aa5ff44c8 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt @@ -51,7 +51,6 @@ import javax.inject.Inject private const val HEADER_FILE_NAME = "header.png" private const val AVATAR_FILE_NAME = "avatar.png" - /** * Conveniently groups Profile Data users can modify in the UI. */ @@ -59,7 +58,7 @@ internal data class ProfileData( val displayName: String, val note: String, val locked: Boolean, - val fields: List, + val fields: List ) class EditProfileViewModel @Inject constructor( @@ -151,7 +150,7 @@ class EditProfileViewModel @Inject constructor( } } - internal fun hasUnsavedChanges(newProfileData: ProfileData) : Boolean { + internal fun hasUnsavedChanges(newProfileData: ProfileData): Boolean { val encoded = encodeChangedProfileFields(newProfileData) // If all fields are null, there are no changes. return !encoded.allFieldsAreNull() @@ -225,10 +224,10 @@ class EditProfileViewModel @Inject constructor( val field3: Pair?, val field4: Pair?, val header: MultipartBody.Part?, - val avatar: MultipartBody.Part?, + val avatar: MultipartBody.Part? ) { - fun allFieldsAreNull() = displayName == null && note == null && locked == null - && avatar == null && header == null && field1 == null && field2 == null - && field3 == null && field4 == null + fun allFieldsAreNull() = displayName == null && note == null && locked == null && + avatar == null && header == null && field1 == null && field2 == null && + field3 == null && field4 == null } }