Posts

Showing posts from December, 2022

Implementing a Custom Search Bar

Image
  This tutorial will show you how to create a custom search bar in your app that will return a list of items by title or date specified in the search bar. This list will refresh every time the user types a new character or deletes the query with a half second delay (debounce) to ensure the user has paused typing before showing the result. This app shows a list of hiking trips the user has taken and saved to the database as a list. The user can update what is shown in the list by both making a search query and deleting a trip. This list is initially fetched from the database and the search query operates on the list currently in memory. Deleting a trip notifies the app to update the database and update the tripFlow in the ViewModel. Trip.kt @Entity data class Trip ( @PrimaryKey (autoGenerate = true ) var id : Int = 0 , var date : Long = System .currentTimeMillis() , var title : String = "" , var path : List < PathMarker > = mutableListOf () , var pho...