Skip to content

Conversation

@junieberry
Copy link

dim처리는 더 공부해보고 추가해보겠습니다..!

  1. 검색 기록 화면
    image

  2. 검색 기록에서 검색 기록 항목 누른 화면
    image

  3. 검색 결과 없는 화면
    image

  4. 검색 오류가 발생한 화면
    image

}

companion object {
lateinit var instance: App
Copy link
Contributor

Choose a reason for hiding this comment

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

이런 접근 방식은 좋지 못해요 전역에서 사용하는건데 safe하지 않습니다!
잘 생각해보면 DI로 ViewModel init할때 넣으면 좋을 것 같네요

Comment on lines 22 to +23
holder.bind(movies[position])
holder.itemView.setOnClickListener{movieClickListener(movies[position])}
holder.itemView.setOnClickListener { movieClickListener(movies[position]) }
Copy link
Contributor

Choose a reason for hiding this comment

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

binding 내부로 click listener를 넣어서 사용하는게 더 깔끔해보여요!

)[MainViewModel::class.java]


if (intent.getStringExtra("title") != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

스코프 함수를 써서 해보세요!


@BindingAdapter("bind_history_list")
fun setHistory(recyclerView: RecyclerView, histories: ArrayList<String>?) {
if (histories != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

여기도 스코프함수!

Comment on lines +18 to +23
if (empty) {
textView.visibility = View.VISIBLE
}
else {
textView.visibility = View.GONE
}
Copy link
Contributor

Choose a reason for hiding this comment

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

삼항 연산을 쓰는게 더 깔끔할거같아요

import org.w3c.dom.Text

@BindingAdapter("bind_visible_if")
fun setVisibility(textView:TextView, empty:Boolean) {
Copy link
Contributor

Choose a reason for hiding this comment

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

view 다음에 들어오는 데이터는 nullable하게 받아줘야 합니다!

}
}
override fun onFailure(call: Call<MovieResponse>, t: Throwable) {
Toast.makeText(App.instance.applicationContext, "검색 도중 오류가 발생했습니다.", Toast.LENGTH_SHORT).show()
Copy link
Contributor

Choose a reason for hiding this comment

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

viewModel은 명령을 내리는 곳이지 ui에 직접 관여하면 안됩니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants