From 537b649320d63a96cefc13a5023aa0fdf6b45a34 Mon Sep 17 00:00:00 2001 From: ddangcong80 Date: Mon, 8 Jul 2024 14:13:59 +0900 Subject: [PATCH] refactor: Change search criteria to category --- .../campus/tech/kakao/map/repository/SearchRepository.kt | 6 +++--- .../main/java/campus/tech/kakao/map/view/SearchAdapter.kt | 4 +++- .../java/campus/tech/kakao/map/viewmodel/SearchViewModel.kt | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/campus/tech/kakao/map/repository/SearchRepository.kt b/app/src/main/java/campus/tech/kakao/map/repository/SearchRepository.kt index 6e1675e7..b932a1a2 100644 --- a/app/src/main/java/campus/tech/kakao/map/repository/SearchRepository.kt +++ b/app/src/main/java/campus/tech/kakao/map/repository/SearchRepository.kt @@ -45,13 +45,13 @@ class SearchRepository(context: Context) { } } - fun getSearchPlaces(placeName: String): MutableList { + fun getSearchPlaces(placeCategory: String): MutableList { val db: SQLiteDatabase = dbHelper.readableDatabase val places = mutableListOf() 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, diff --git a/app/src/main/java/campus/tech/kakao/map/view/SearchAdapter.kt b/app/src/main/java/campus/tech/kakao/map/view/SearchAdapter.kt index b243e450..80c15fef 100644 --- a/app/src/main/java/campus/tech/kakao/map/view/SearchAdapter.kt +++ b/app/src/main/java/campus/tech/kakao/map/view/SearchAdapter.kt @@ -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) : +class SearchAdapter( + private val places: List +) : RecyclerView.Adapter() { class SearchViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { diff --git a/app/src/main/java/campus/tech/kakao/map/viewmodel/SearchViewModel.kt b/app/src/main/java/campus/tech/kakao/map/viewmodel/SearchViewModel.kt index 32de9c98..71ab6891 100644 --- a/app/src/main/java/campus/tech/kakao/map/viewmodel/SearchViewModel.kt +++ b/app/src/main/java/campus/tech/kakao/map/viewmodel/SearchViewModel.kt @@ -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) } } \ No newline at end of file