make an if/else check clearer

This commit is contained in:
tibbi 2018-10-28 11:23:13 +01:00
parent 952cce20c0
commit 6de4f09319
2 changed files with 5 additions and 3 deletions

View File

@ -94,12 +94,12 @@ data class Contact(val id: Int, var prefix: String, var firstName: String, var m
val suffixComma = if (suffix.isEmpty()) "" else ", $suffix"
val fullName = "$prefix $firstPart $lastPart$suffixComma".trim()
return if (fullName.isEmpty()) {
if (organization.isEmpty()) {
emails.firstOrNull()?.value?.trim() ?: ""
} else {
if (organization.isNotEmpty()) {
var fullOrganization = if (organization.jobPosition.isEmpty()) "" else "${organization.jobPosition}, "
fullOrganization += organization.company
fullOrganization.trim().trimEnd(',')
} else {
emails.firstOrNull()?.value?.trim() ?: ""
}
} else {
fullName

View File

@ -2,4 +2,6 @@ package com.simplemobiletools.contacts.models
data class Organization(var company: String, var jobPosition: String) {
fun isEmpty() = company.isEmpty() && jobPosition.isEmpty()
fun isNotEmpty() = !isEmpty()
}