Skip to content

Commit

Permalink
refactor: Change search criteria to category
Browse files Browse the repository at this point in the history
  • Loading branch information
ddangcong80 committed Jul 8, 2024
1 parent 489b13f commit 537b649
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class SearchRepository(context: Context) {
}
}

fun getSearchPlaces(placeName: String): MutableList<Place> {
fun getSearchPlaces(placeCategory: String): MutableList<Place> {
val db: SQLiteDatabase = dbHelper.readableDatabase
val places = mutableListOf<Place>()
var cursor: Cursor? = null
try {
val selection = "${PlaceContract.PlaceEntry.COLUMN_PLACE_NAME} LIKE ?"
val selectionArgs = arrayOf("$placeName%")
val selection = "${PlaceContract.PlaceEntry.COLUMN_PLACE_CATEGORY} LIKE ?"
val selectionArgs = arrayOf("$placeCategory%")

cursor = db.query(
PlaceContract.PlaceEntry.TABLE_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import androidx.recyclerview.widget.RecyclerView
import campus.tech.kakao.map.R
import campus.tech.kakao.map.model.Place

class SearchAdapter(private val places: List<Place>) :
class SearchAdapter(
private val places: List<Place>
) :
RecyclerView.Adapter<SearchAdapter.SearchViewHolder>() {

class SearchViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SearchViewModel(application: Application) : AndroidViewModel(application)
searchRepo.insertPlaceDummyData(name, address, category)
}

fun searchPlaces(placeName: String) {
_places.value = searchRepo.getSearchPlaces(placeName)
fun searchPlaces(placeCategory: String) {
_places.value = searchRepo.getSearchPlaces(placeCategory)
}
}

0 comments on commit 537b649

Please sign in to comment.