-
Notifications
You must be signed in to change notification settings - Fork 88
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
HW-6 AAC ViewModel LiveData 적용 #462
Conversation
} | ||
|
||
@BindingAdapter("setData") | ||
fun RecyclerView.setData(movieData: List<Any>?) { | ||
when (movieData) { | ||
null -> { | ||
} | ||
else -> { | ||
if (movieData.isNotEmpty()){ | ||
(this.adapter as MovieAdapter).setMovieItemList(movieData as List<Movie>) | ||
} | ||
} | ||
} |
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.
삭제하고 난 뒤 Adapter 에 데이터를 넣어주는 부분이 보이지 않는데, 혹시 어느부분에서 데이터를 set 하는지 궁금합니다.
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.
앗,,,리사이클러뷰에 데이터가 안 뿌려지는게 서버에 문제가 있어서 인줄 알고 철썩같이 믿고 있었는데, 데이터 set 해주는 걸 삭제만 하고 다시 만들지 않아서였네요.. 해결해주셔서 감사합니다!
05d9abe
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.
근데 BindingAdapter를 통해서 데이터를 변경하는 거랑 지금 형태처럼 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.
저는 어댑터를 지웠다가 다시만들었어요. LifecycleOwner 를 넘겨주지 않아서 안되는줄 알았거든요. 지금은 다시 바인딩으로 바꿨는데 둘다 되더라구요! 전 리싸이클러뷰에 데이터 바인딩 하는부분도 남겨놓고 싶어서 어댑터로 다시 바꿨는데 뭐가 맞는지는 잘 모르겠어요 ㅎㅎ
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.
수고하셨어요!!
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>> { |
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.
기존에 BindingAdapter로 했던 형태로 변경해주세요
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.
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>() |
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.
전부 val로 변경해주세요
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.
var hasWrongChar = MutableLiveData<Boolean>() | ||
var isEmptyKeyword = MutableLiveData<Boolean>() | ||
var isEmptyMovieData = MutableLiveData<Boolean>() |
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.
단순 이벤트를 던지기 위한 용도라면 Unit으로 type을 변경해도 됩니다.
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.
LGTM ✊ ✌️ 👋
바꾸고 나서 검색어 입력 뒤 검색어를 누르면 이러한 에러가 뜹니다.
E/error is :: java.net.UnknownHostException: Unable to resolve host "openapi.naver.com": No address associated with hostname
이 이유가 제가 잘못 바꿔서 그런건지 아니면 네이버 api 서버에 문제가 있는건지 모르겠어요..