Skip to content

Commit

Permalink
ok no it works the way we want!
Browse files Browse the repository at this point in the history
- updates list in real time as you type in search
- arrow back lets you keep search
- x button in search bar clears search
- physical back button clears search
  • Loading branch information
williscool committed Sep 27, 2024
1 parent 43ea9bb commit 9bc0c2f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,10 @@ class EventListAdapter(
events = newEvents;
}

if (searchString != null && searchString != ""){
if (!searchString.isNullOrEmpty()){
events = allEvents.filter { ev -> searchString?.let { ev.title.lowercase().contains(it.lowercase()) } == true }.toTypedArray()
} else {
events = allEvents
}

eventsPendingRemoval.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,16 @@ class MainActivity : AppCompatActivity(), EventListCallback {
}
})

val closebutton: View = searchView.findViewById(androidx.appcompat.R.id.search_close_btn)

closebutton.setOnClickListener {
searchView.setQuery("",false)
searchView.clearFocus()
adapter.setSearchText(null)
adapter.setEventsToDisplay()
true
}

val menuItem = menu.findItem(R.id.action_snooze_all)
if (menuItem != null) {
menuItem.isEnabled = adapter.itemCount > 0
Expand Down

0 comments on commit 9bc0c2f

Please sign in to comment.