diff --git a/app/src/main/java/com/hiddenramblings/tagmo/adapter/BrowserAdapter.kt b/app/src/main/java/com/hiddenramblings/tagmo/adapter/BrowserAdapter.kt index 9bb1d9245..afbc230c1 100644 --- a/app/src/main/java/com/hiddenramblings/tagmo/adapter/BrowserAdapter.kt +++ b/app/src/main/java/com/hiddenramblings/tagmo/adapter/BrowserAdapter.kt @@ -190,17 +190,17 @@ class BrowserAdapter( inner class AmiiboFilter : Filter() { override fun performFiltering(constraint: CharSequence?): FilterResults { - val query = constraint?.toString() ?: "" + val query = constraint?.toString()?.trim { it <= ' ' } ?: "" val filterResults = FilterResults() data = ArrayList(settings.amiiboFiles) - if (query.trim { it <= ' ' }.isEmpty()) { + if (query.isEmpty()) { filterResults.count = data.size filterResults.values = data return filterResults } - settings.query = query + settings.query = constraint?.toString() val tempList:ArrayList = arrayListOf() - val queryText = query.trim { it <= ' ' }.lowercase(Locale.getDefault()) + val queryText = query.lowercase(Locale.getDefault()) val amiiboManager = settings.amiiboManager val amiiboFiles = settings.amiiboFiles amiiboFiles.forEach { amiiboFile -> diff --git a/app/src/main/java/com/hiddenramblings/tagmo/adapter/FoomiiboAdapter.kt b/app/src/main/java/com/hiddenramblings/tagmo/adapter/FoomiiboAdapter.kt index af6ab8c4a..eb6d0b7aa 100644 --- a/app/src/main/java/com/hiddenramblings/tagmo/adapter/FoomiiboAdapter.kt +++ b/app/src/main/java/com/hiddenramblings/tagmo/adapter/FoomiiboAdapter.kt @@ -164,21 +164,19 @@ class FoomiiboAdapter( inner class FoomiiboFilter : Filter() { override fun performFiltering(constraint: CharSequence?): FilterResults { - val query = constraint?.toString() ?: "" + val query = constraint?.toString()?.trim { it <= ' ' } ?: "" val filterResults = FilterResults() - if (query.trim { it <= ' ' }.isEmpty()) { - filterResults.count = data.size - filterResults.values = data - } - settings.query = query settings.amiiboManager?.let { data = ArrayList(it.amiibos.values) } ?: data.clear() - val tempList: ArrayList = arrayListOf() - val queryText = query.trim { it <= ' ' }.lowercase(Locale.getDefault()) - data.forEach { - if (settings.amiiboContainsQuery(it, queryText)) tempList.add(it) + if (query.isEmpty()) { + filterResults.count = data.size + filterResults.values = data + return filterResults } + settings.query = constraint?.toString() + val queryText = query.lowercase(Locale.getDefault()) + val tempList: List = data.filter { settings.amiiboContainsQuery(it, queryText) } filterResults.count = tempList.size filterResults.values = tempList return filterResults