apply attendees search string to contact names too, not just emails

This commit is contained in:
tibbi 2019-03-13 22:49:25 +01:00
parent 362599fcdf
commit 62bea960e3
1 changed files with 3 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import android.widget.Filter
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.models.Attendee import com.simplemobiletools.calendar.pro.models.Attendee
import com.simplemobiletools.commons.extensions.normalizeString
import kotlinx.android.synthetic.main.item_autocomplete.view.* import kotlinx.android.synthetic.main.item_autocomplete.view.*
class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val contacts: ArrayList<Attendee>) : ArrayAdapter<Attendee>(activity, 0, contacts) { class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val contacts: ArrayList<Attendee>) : ArrayAdapter<Attendee>(activity, 0, contacts) {
@ -30,8 +31,9 @@ class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val contacts: Ar
val filterResults = Filter.FilterResults() val filterResults = Filter.FilterResults()
if (constraint != null) { if (constraint != null) {
resultList.clear() resultList.clear()
val searchString = constraint.toString().normalizeString()
contacts.forEach { contacts.forEach {
if (it.email.contains(constraint, true)) { if (it.email.contains(searchString, true) || it.name.contains(searchString, true)) {
resultList.add(it) resultList.add(it)
} }
} }