-
Notifications
You must be signed in to change notification settings - Fork 0
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
[MOD/#77] search / 코드 수정 및 기능 추가 #82
Conversation
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.
고생하셨습니다!
key event와 관련된 처리 잘 보고 갑니다 🤭
app/src/main/java/com/keyneez/presentation/main/search/SearchActivity.kt
Outdated
Show resolved
Hide resolved
private fun initSearchBtnClickListener() { | ||
binding.btnSearchResult.setOnKeyListener { v, keyCode, event -> | ||
if ((event.action == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { | ||
viewModel.getSearchPostData() | ||
setupSearchData() | ||
true | ||
} else { | ||
false | ||
} | ||
} | ||
binding.etSearchContent.setOnEditorActionListener(object : TextView.OnEditorActionListener { | ||
override fun onEditorAction(v: TextView?, actionId: Int, event: KeyEvent?): Boolean { | ||
if (actionId == EditorInfo.IME_ACTION_SEARCH) { | ||
viewModel.getSearchPostData() | ||
setupSearchData() | ||
return true | ||
} | ||
return false | ||
} | ||
}) | ||
} |
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.
setupSearchData()
는 onCreate에서 이미 호출되고 있는데 다른 함수들에서 중복되어서 다시 호출되고 있네요!
livedata를 observe한다는 게 무슨 의미인지 한번 찾아보셨으면 좋겠어요 :)
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.
중복되어서 호출한 이유는 검색버튼을 눌렀을 때도 검색이 되고, 엔터를 눌렀을 때도 검색이 되게끔 하고 싶어 그 두가지 기능을 다 구현하였기 때문에 중복 호출을 하였습니다..! 혹시 다른 방법을 알려주실 수 있나용??
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.
observe하는 함수는 초기에 한번만 호출해주어도 정상적으로 작동할 겁니다!
livedata와 observe 개념을 조금 더 찾아보시고 그래도 이해가 안 가시면 알려주세요!
app/src/main/java/com/keyneez/presentation/main/search/SearchActivity.kt
Show resolved
Hide resolved
app/src/main/java/com/keyneez/presentation/main/search/SearchActivity.kt
Outdated
Show resolved
Hide resolved
@@ -57,7 +56,7 @@ | |||
android:layout_height="wrap_content" | |||
android:layout_marginEnd="12dp" | |||
android:layout_marginBottom="4dp" | |||
android:background="@null" | |||
android:background="@android:color/transparent" |
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.
혹시 이렇게 바꾼 이유가 뭔가요?
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.
바탕을 투명색으로 바꾸기 위해 검색 후 저렇게 고쳤습니다!
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.
@null
로 지정해도 아이콘 배경이 투명하게 설정된다고 알고 있었는데 아니었나요?
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.
앗 의미적으로만 다르고 동일시 되는 거 같습니다. 아래 글처럼 null이 더 좋다고 하여 다시 바꾸었습니다!
https://stackoverflow.com/questions/9311123/is-there-any-diff-null-vs-00000000
커밋하실 때 "코드 리뷰 반영" 보다는 어떤 로직을 수정했는지 구체적으로 명시해주시는 게 유지보수나 형상 관리 측면에서 도움이 될 것 같습니다! EX) 함수 네이밍 컨벤션 반영 |
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.
LGTM 💚
viewModel.searchList.observe(this) { | ||
searchAdapter.data = it | ||
searchAdapter.notifyDataSetChanged() | ||
binding.tvSearchCount.setText(it.size.toString()) | ||
if (it.size.toString() == "0") { |
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.
it.size == 0
으로 하면 안 되나요?
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.
가능해요!! 수정하였습니다
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid android:color="@color/gray200" /> | ||
<corners | ||
android:bottomLeftRadius="14dp" | ||
android:bottomRightRadius="14dp" /> | ||
</shape> |
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.
지금 봤는데 shape 파일 네이밍 센스 있게 잘 하셨네요 👍👍
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.
LGTM❤️❤️
넘 수고 많았어요
관련 이슈
작업 내역
-검색 결과 0개면 토스트 띄우기
-엔터 누르면 검색되도록 수정
-긴 문자열 입력 시 검색 버튼 오른쪽에 문자 보이는 거 수정
-이미지버튼 background 투명하게 수정
PR 포인트
실행 화면