Apply klint recommendations.

This commit is contained in:
Martin Marconcini 2023-08-19 17:57:25 +02:00
parent 461ec8d722
commit 634f020ffa
No known key found for this signature in database
2 changed files with 8 additions and 9 deletions

View File

@ -210,7 +210,7 @@ class EditProfileActivity : BaseActivity(), Injectable {
if (!viewModel.hasUnsavedChanges(gatherProfileData())) finish() if (!viewModel.hasUnsavedChanges(gatherProfileData())) finish()
lifecycleScope.launch { lifecycleScope.launch {
when(showConfirmationDialog()) { when (showConfirmationDialog()) {
AlertDialog.BUTTON_POSITIVE -> save() AlertDialog.BUTTON_POSITIVE -> save()
else -> finish() else -> finish()
} }
@ -232,7 +232,7 @@ class EditProfileActivity : BaseActivity(), Injectable {
displayName = binding.displayNameEditText.text.toString(), displayName = binding.displayNameEditText.text.toString(),
note = binding.noteEditText.text.toString(), note = binding.noteEditText.text.toString(),
locked = binding.lockedCheckBox.isChecked, locked = binding.lockedCheckBox.isChecked,
fields = accountFieldEditAdapter.getFieldData(), fields = accountFieldEditAdapter.getFieldData()
) )
private fun observeImage( private fun observeImage(

View File

@ -51,7 +51,6 @@ import javax.inject.Inject
private const val HEADER_FILE_NAME = "header.png" private const val HEADER_FILE_NAME = "header.png"
private const val AVATAR_FILE_NAME = "avatar.png" private const val AVATAR_FILE_NAME = "avatar.png"
/** /**
* Conveniently groups Profile Data users can modify in the UI. * Conveniently groups Profile Data users can modify in the UI.
*/ */
@ -59,7 +58,7 @@ internal data class ProfileData(
val displayName: String, val displayName: String,
val note: String, val note: String,
val locked: Boolean, val locked: Boolean,
val fields: List<StringField>, val fields: List<StringField>
) )
class EditProfileViewModel @Inject constructor( 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) val encoded = encodeChangedProfileFields(newProfileData)
// If all fields are null, there are no changes. // If all fields are null, there are no changes.
return !encoded.allFieldsAreNull() return !encoded.allFieldsAreNull()
@ -225,10 +224,10 @@ class EditProfileViewModel @Inject constructor(
val field3: Pair<RequestBody, RequestBody>?, val field3: Pair<RequestBody, RequestBody>?,
val field4: Pair<RequestBody, RequestBody>?, val field4: Pair<RequestBody, RequestBody>?,
val header: MultipartBody.Part?, val header: MultipartBody.Part?,
val avatar: MultipartBody.Part?, val avatar: MultipartBody.Part?
) { ) {
fun allFieldsAreNull() = displayName == null && note == null && locked == null fun allFieldsAreNull() = displayName == null && note == null && locked == null &&
&& avatar == null && header == null && field1 == null && field2 == null avatar == null && header == null && field1 == null && field2 == null &&
&& field3 == null && field4 == null field3 == null && field4 == null
} }
} }