Skip to content

Commit

Permalink
Restore the filtering to the original structure
Browse files Browse the repository at this point in the history
  • Loading branch information
AbandonedCart committed Dec 10, 2024
1 parent 7272572 commit 3f28db4
Showing 1 changed file with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,23 @@ class FoomiiboAdapter(

inner class FoomiiboFilter : Filter() {
override fun performFiltering(constraint: CharSequence?): FilterResults {
val query = constraint?.trim { it <= ' ' }?.toString()
val query = constraint?.toString() ?: ""
val filterResults = FilterResults()
if (query.isNullOrBlank()) {
if (query.trim { it <= ' ' }.isEmpty()) {
filterResults.count = data.size
filterResults.values = data
} else {
settings.query = query
settings.amiiboManager?.let {
data = ArrayList(it.amiibos.values)
} ?: data.clear()
val tempList: ArrayList<Amiibo> = arrayListOf()
val queryText = query.trim { it <= ' ' }.lowercase(Locale.getDefault())
data.forEach {
if (settings.amiiboContainsQuery(it, queryText)) tempList.add(it)
}
filterResults.count = tempList.size
filterResults.values = tempList
}
settings.query = query
settings.amiiboManager?.let {
data = ArrayList(it.amiibos.values)
} ?: data.clear()
val tempList: ArrayList<Amiibo> = arrayListOf()
val queryText = query.trim { it <= ' ' }.lowercase(Locale.getDefault())
data.forEach {
if (settings.amiiboContainsQuery(it, queryText)) tempList.add(it)
}
filterResults.count = tempList.size
filterResults.values = tempList
return filterResults
}

Expand Down

0 comments on commit 3f28db4

Please sign in to comment.