Skip to content

Commit bd9a150

Browse files
author
Jan Guegel
committed
fix last usage of contains() without normalizeString in search context
fix missing expection toast Signed-off-by: Jan Guegel <[email protected]>
1 parent 4dbb8f8 commit bd9a150

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

app/src/main/kotlin/org/fossify/filemanager/activities/MimeTypesActivity.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
133133
override fun selectedPaths(paths: ArrayList<String>) {}
134134

135135
fun searchQueryChanged(text: String) {
136-
val searchText = text.trim()
137-
lastSearchedText = searchText
136+
val normalizedText = text.normalizeString()
137+
val searchNormalizedText = normalizedText.trim()
138+
lastSearchedText = searchNormalizedText
138139
when {
139-
searchText.isEmpty() -> {
140+
searchNormalizedText.isEmpty() -> {
140141
binding.apply {
141142
mimetypesFastscroller.beVisible()
142143
getRecyclerAdapter()?.updateItems(storedItems)
@@ -145,7 +146,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
145146
}
146147
}
147148

148-
searchText.length == 1 -> {
149+
searchNormalizedText.length == 1 -> {
149150
binding.apply {
150151
mimetypesFastscroller.beGone()
151152
mimetypesPlaceholder.beVisible()
@@ -155,11 +156,13 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
155156

156157
else -> {
157158
ensureBackgroundThread {
158-
if (lastSearchedText != searchText) {
159+
if (lastSearchedText != searchNormalizedText) {
159160
return@ensureBackgroundThread
160161
}
161162

162-
val listItems = storedItems.filter { it.name.contains(searchText, true) } as ArrayList<ListItem>
163+
val listItems = storedItems.filter {
164+
it.name.normalizeString().contains(searchNormalizedText, true)
165+
} as ArrayList<ListItem>
163166

164167
runOnUiThread {
165168
getRecyclerAdapter()?.updateItems(listItems, text)
@@ -339,6 +342,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
339342
}
340343
}
341344
} catch (e: Exception) {
345+
showErrorToast(e)
342346
}
343347
}
344348
} catch (e: Exception) {

0 commit comments

Comments
 (0)