fix the sorting of organization contacts

This commit is contained in:
tibbi 2018-08-02 22:02:10 +02:00
parent 73ff7f440e
commit 23d6e54718
1 changed files with 10 additions and 2 deletions

View File

@ -16,8 +16,8 @@ data class Contact(val id: Int, var prefix: String, var firstName: String, var m
}
override fun compareTo(other: Contact): Int {
val firstString: String
val secondString: String
var firstString: String
var secondString: String
when {
sorting and SORT_BY_FIRST_NAME != 0 -> {
@ -34,6 +34,14 @@ data class Contact(val id: Int, var prefix: String, var firstName: String, var m
}
}
if (firstString.isEmpty() && firstName.isEmpty() && middleName.isEmpty() && surname.isEmpty() && organization.company.isNotEmpty()) {
firstString = organization.company
}
if (secondString.isEmpty() && other.firstName.isEmpty() && other.middleName.isEmpty() && other.surname.isEmpty() && other.organization.company.isNotEmpty()) {
secondString = other.organization.company
}
var result = if (firstString.firstOrNull()?.isLetter() == true && secondString.firstOrNull()?.isLetter() == false) {
-1
} else if (firstString.firstOrNull()?.isLetter() == false && secondString.firstOrNull()?.isLetter() == true) {