-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
부산대 Android_김민혁_2주차_과제_STEP2 #49
base: main
Are you sure you want to change the base?
Conversation
- Added a new view 'activity_search.xml' which includes a simple search bar layout using SearchView.
- Added SearchMainActivity which is activity for activity_search.xml
These data would be results of searching.
Added information related to local database.
- Renamed DBHelper to PlaceDBHelper - Added PlaceDBHelper class with methods to create the PlaceTable and insert initial place data - Implemented the SearchHistoryDBHelper class to manage search history in a new SearchHistoryTable - Added methods to insert, delete, and retrieve search history entries Closes #789
- Moved the Place data class from PlaceDBHelper to its own file for better code organization.
…history - Implemented SearchHistoryRecyclerViewAdapter to manage and display search history items in a RecyclerView. - Added ViewHolder class for binding search history items and handling item clicks and deletions. - Updated onBindViewHolder to handle click events for item selection and deletion, including updating the RecyclerView.
…esults - Updated the filtering logic in SearchActivity to correctly filter search results based on the entered query. - reset previous commits by hard option to find error. recommit normally operating files(activity_search.xml, AndroidManifest.xml, DBHelper.kt, SearchMainActivity.kt)
- Extracted PlaceDBHelper for managing the PlaceTable database operations. - Extracted SearchHistoryDBHelper for managing the SearchHistoryTable database operations. - Deleted DBHelper.kt which previously contained combined functionality.
- Updated visibility attribute of RecyclerView with ID 'recycler_view' to 'visible' to ensure search results are displayed correctly. - Adjusted visibility attribute of TextView with ID 'no_results' to 'gone' to hide the message when search results are present. - To fix visibility bug of no_result.
…rations accordingly
…rations accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 변수 선언을 정확하게 하는 것이 어렵습니다. lateinit을 언제 써야 하는지, 어떤 것은 그냥 val로 선언해도 되는 지 등을 개인적인 감으로 설정한 경향이 있는데, 대략적인 가이드라인이 있으면 좋을 것 같습니다.
나중에 생성해야할때 쓰긴 합니다만... immutable을 보장할수 없어서 저는 lazy
를 더 많이 사용합니다. 생성이 오래걸리거나 다른 값이 필요하면 �이런 지연 생성자를 사용해도 좋은데 그 외에는 즉시 하시면 될거 같네요
- 콜백 함수를 넘길 때, 람다 함수가 군데군데 들어가 있으니 코드가 보기 불편한 점을 현업에서는 어떻게 개선하시는 지 궁금합니다.
이건 어떤 상황인지 잘 모르겠는데 코드 예시를 주시겠어요?
address TEXT NOT NULL | ||
) | ||
""" | ||
db?.execSQL(placeTableSQL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(지금 대응하지 않으셔도 됩니다)
db에 쿼리를 날리는건 에러가 발생할수 있는 대표적인 케이스중 하나입니다
어떤 에러가 발생할수 있는지와 케이스별로 어떻게 대응하면 좋을지 한번 고민 해보시겠어요?
holder.searchHistoryDeleteBtn.setOnClickListener { | ||
onItemDelete(index) | ||
notifyItemRemoved(index) | ||
notifyItemRangeChanged(index, searchHistory.size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RecyclerView가 변경감지를 최소화하도록 잘 작업하셨군요 👏
그런데 이런 작업을 더 쉽게 해주는 DiffUtil이란 친구도 있습니다.
나중에 한번 알아보세요!
return db.delete("SearchHistoryTable", "`name` = ?", arrayOf(name)) | ||
} | ||
|
||
fun getAllSearchHistory(): MutableList<Place> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
결과값을 MutableList로 보낼 필요가 있나요?
대부분 경우에서 수정을 제한하고자 Immutable한 값을 넘겨주곤 합니다
PR 드립니다! MVVM 패턴은 너무 적용해보고 싶었으나 시간 부족으로 실패하였습니다😢
동시에 몇 가지 질문도 드리고 싶습니다.
이외에도 개선할 점 많이 지적 부탁드립니다!