fix the sorting of organization contacts

This commit is contained in:
tibbi
2018-08-02 22:02:10 +02:00
parent 73ff7f440e
commit 23d6e54718

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 { override fun compareTo(other: Contact): Int {
val firstString: String var firstString: String
val secondString: String var secondString: String
when { when {
sorting and SORT_BY_FIRST_NAME != 0 -> { 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) { var result = if (firstString.firstOrNull()?.isLetter() == true && secondString.firstOrNull()?.isLetter() == false) {
-1 -1
} else if (firstString.firstOrNull()?.isLetter() == false && secondString.firstOrNull()?.isLetter() == true) { } else if (firstString.firstOrNull()?.isLetter() == false && secondString.firstOrNull()?.isLetter() == true) {