Skip to content

HW-6 AAC ViewModel LiveData 적용 #462

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

Merged

Conversation

ghkdua1829
Copy link
Contributor

@ghkdua1829 ghkdua1829 commented Feb 6, 2020

바꾸고 나서 검색어 입력 뒤 검색어를 누르면 이러한 에러가 뜹니다.
E/error is :: java.net.UnknownHostException: Unable to resolve host "openapi.naver.com": No address associated with hostname
이 이유가 제가 잘못 바꿔서 그런건지 아니면 네이버 api 서버에 문제가 있는건지 모르겠어요..

@ghkdua1829 ghkdua1829 added the Review Needed 리뷰어의 리뷰가 필요한 경우 label Feb 6, 2020
@ghkdua1829 ghkdua1829 requested a review from handnew04 February 6, 2020 16:28
@ghkdua1829 ghkdua1829 self-assigned this Feb 6, 2020
Comment on lines 27 to 39
}

@BindingAdapter("setData")
fun RecyclerView.setData(movieData: List<Any>?) {
when (movieData) {
null -> {
}
else -> {
if (movieData.isNotEmpty()){
(this.adapter as MovieAdapter).setMovieItemList(movieData as List<Movie>)
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

삭제하고 난 뒤 Adapter 에 데이터를 넣어주는 부분이 보이지 않는데, 혹시 어느부분에서 데이터를 set 하는지 궁금합니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗,,,리사이클러뷰에 데이터가 안 뿌려지는게 서버에 문제가 있어서 인줄 알고 철썩같이 믿고 있었는데, 데이터 set 해주는 걸 삭제만 하고 다시 만들지 않아서였네요.. 해결해주셔서 감사합니다!
05d9abe

Copy link
Contributor Author

@ghkdua1829 ghkdua1829 Feb 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

근데 BindingAdapter를 통해서 데이터를 변경하는 거랑 지금 형태처럼 Observe를 통해서 데이터를 변경하는 거 둘 중에 하나 아무거나 쓰면 되는 건지 궁금합니다.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 어댑터를 지웠다가 다시만들었어요. LifecycleOwner 를 넘겨주지 않아서 안되는줄 알았거든요. 지금은 다시 바인딩으로 바꿨는데 둘다 되더라구요! 전 리싸이클러뷰에 데이터 바인딩 하는부분도 남겨놓고 싶어서 어댑터로 다시 바꿨는데 뭐가 맞는지는 잘 모르겠어요 ㅎㅎ

@ghkdua1829 ghkdua1829 added Review Needed 리뷰어의 리뷰가 필요한 경우 and removed Review Needed 리뷰어의 리뷰가 필요한 경우 labels Feb 7, 2020
Copy link
Contributor

@handnew04 handnew04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨어요!!

@handnew04 handnew04 requested a review from sjjeong February 8, 2020 02:46
@handnew04 handnew04 added the Mentor Needed 멘토가 필요한 경우 label Feb 8, 2020
showDataNum(vm.movieDataNum.get()!!)
vm.hasWrongChar.observe(this, Observer<Boolean> { showNotAvailableKeyword() })
vm.movieDataNum.observe(this, Observer<Int> { showDataNum(vm.movieDataNum.value!!) })
vm.movieData.observe(this, Observer<List<Movie>> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존에 BindingAdapter로 했던 형태로 변경해주세요

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 13 to 18
var hasWrongChar = MutableLiveData<Boolean>()
var isEmptyKeyword = MutableLiveData<Boolean>()
var isEmptyMovieData = MutableLiveData<Boolean>()
var movieData = MutableLiveData<List<Movie>>()
var errorToast = MutableLiveData<Throwable>()
var movieDataNum = MutableLiveData<Int>()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전부 val로 변경해주세요

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 13 to 15
var hasWrongChar = MutableLiveData<Boolean>()
var isEmptyKeyword = MutableLiveData<Boolean>()
var isEmptyMovieData = MutableLiveData<Boolean>()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

단순 이벤트를 던지기 위한 용도라면 Unit으로 type을 변경해도 됩니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjjeong sjjeong added Answer Needed PR담당자의 응답이 필요한 경우 and removed Review Needed 리뷰어의 리뷰가 필요한 경우 labels Feb 8, 2020
@ghkdua1829 ghkdua1829 added Review Needed 리뷰어의 리뷰가 필요한 경우 and removed Answer Needed PR담당자의 응답이 필요한 경우 labels Feb 9, 2020
Copy link
Collaborator

@sjjeong sjjeong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✊ ✌️ 👋

@ghkdua1829 ghkdua1829 merged commit 679bab0 into StudyFork:class07/ghkdua1829 Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mentor Needed 멘토가 필요한 경우 Review Needed 리뷰어의 리뷰가 필요한 경우
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants