@@ -21,26 +21,29 @@ import kotlinx.android.synthetic.main.item_autocomplete_name_number.view.item_au
2121import kotlinx.android.synthetic.main.item_autocomplete_name_number.view.item_autocomplete_name
2222import kotlinx.android.synthetic.main.item_autocomplete_name_number.view.item_autocomplete_number
2323
24- class AutoCompleteTextViewAdapter (val activity : SimpleActivity , val contacts : ArrayList <Contact >, var enableAutoFill : Boolean = false ) : ArrayAdapter<Contact>(activity, 0 , contacts) {
24+ class AutoCompleteTextViewAdapter (
25+ val activity : SimpleActivity ,
26+ val contacts : ArrayList <Contact >,
27+ var enableAutoFill : Boolean = false
28+ ) : ArrayAdapter<Contact>(activity, 0 , contacts) {
2529 var resultList = ArrayList <Contact >()
2630
2731 override fun getView (position : Int , convertView : View ? , parent : ViewGroup ): View {
2832 val contact = resultList[position]
2933 var listItem = convertView
30- if (listItem == null || listItem.tag != contact.name.isNotEmpty()) {
34+ val nameToUse = contact.getNameToDisplay()
35+ if (listItem == null || listItem.tag != nameToUse.isNotEmpty()) {
3136 listItem = LayoutInflater .from(activity).inflate(R .layout.item_autocomplete_name_number, parent, false )
3237 }
3338
34- val nameToUse = contact.name
35-
3639 val placeholder = BitmapDrawable (activity.resources, SimpleContactsHelper (context).getContactLetterIcon(nameToUse))
3740 listItem!! .apply {
3841 setBackgroundColor(context.getProperBackgroundColor())
3942 item_autocomplete_name.setTextColor(context.getProperTextColor())
4043 item_autocomplete_number.setTextColor(context.getProperTextColor())
4144
42- tag = contact.name .isNotEmpty()
43- item_autocomplete_name.text = contact.name
45+ tag = nameToUse .isNotEmpty()
46+ item_autocomplete_name.text = nameToUse
4447 item_autocomplete_number.text = contact.phoneNumbers.run {
4548 firstOrNull { it.isPrimary }?.normalizedNumber ? : firstOrNull()?.normalizedNumber
4649 }
@@ -70,7 +73,7 @@ class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val contacts: Ar
7073 if (enableAutoFill) {
7174 val searchString = constraint.toString().normalizeString()
7275 contacts.forEach {
73- if (it.name .contains(searchString, true )) {
76+ if (it.getNameToDisplay() .contains(searchString, true )) {
7477 resultList.add(it)
7578 }
7679 }
0 commit comments