Skip to content

Commit

Permalink
Made matchedContacts a val instead of var
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Jun 4, 2024
1 parent 5a1b4aa commit 0354aad
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ContactAdapter(
) : Adapter<ContactViewHolder>() {

private var allContacts: List<MergedContact> = emptyList()
private var matchedContacts = mutableListOf<MatchedContact>()
private val matchedContacts = mutableListOf<MatchedContact>()

private var displayAddUnknownContactButton = true
private var searchQuery = ""
Expand Down Expand Up @@ -105,7 +105,7 @@ class ContactAdapter(

fun searchContacts(text: CharSequence) {

fun performFiltering(constraint: CharSequence): MutableList<MatchedContact> {
fun performFiltering(constraint: CharSequence): List<MatchedContact> {
val searchTerm = constraint.standardize()

val finalUserList = mutableListOf<MatchedContact>()
Expand All @@ -128,7 +128,12 @@ class ContactAdapter(
}

searchQuery = text.toString()
matchedContacts = performFiltering(text)

matchedContacts.apply {
clear()
addAll(performFiltering(text))
}

notifyDataSetChanged()
}

Expand Down

0 comments on commit 0354aad

Please sign in to comment.