@@ -9,6 +9,7 @@ import com.reddit.indicatorfastscroll.FastScrollItemIndicator
99import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
1010import com.simplemobiletools.commons.extensions.*
1111import com.simplemobiletools.commons.helpers.SORT_BY_FIRST_NAME
12+ import com.simplemobiletools.commons.helpers.SORT_BY_MIDDLE_NAME
1213import com.simplemobiletools.commons.helpers.SORT_BY_SURNAME
1314import com.simplemobiletools.contacts.pro.R
1415import com.simplemobiletools.contacts.pro.activities.GroupContactsActivity
@@ -242,7 +243,24 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
242243 private fun setupLetterFastscroller (contacts : ArrayList <Contact >) {
243244 letter_fastscroller.setupWithRecyclerView(fragment_list, { position ->
244245 try {
245- val name = contacts[position].getAvatarLetterName(context)
246+ val contact = contacts[position]
247+ var name = when {
248+ contact.isABusinessContact() -> contact.getFullCompany()
249+ context.config.sorting and SORT_BY_SURNAME != 0 && contact.surname.isNotEmpty() -> contact.surname
250+ context.config.sorting and SORT_BY_MIDDLE_NAME != 0 && contact.middleName.isNotEmpty() -> contact.middleName
251+ context.config.sorting and SORT_BY_FIRST_NAME != 0 && contact.firstName.isNotEmpty() -> contact.firstName
252+ context.config.startNameWithSurname -> contact.surname
253+ else -> contact.firstName
254+ }
255+
256+ if (name.isEmpty() && contact.emails.isNotEmpty()) {
257+ name = contact.emails.first().value
258+ }
259+
260+ if (name.isEmpty()) {
261+ name = contact.getNameToDisplay()
262+ }
263+
246264 var character = if (name.isNotEmpty()) name.substring(0 , 1 ) else " "
247265 if (! character.areLettersOnly()) {
248266 character = " #"
0 commit comments