-
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
Seminar2 필수과제 #9
Conversation
private val binding: ItemHomeHeaderBinding | ||
) : RecyclerView.ViewHolder(binding.root) | ||
|
||
companion object { |
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.
good
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.
YUMMY
class GalleryFragment : Fragment() { | ||
private var _binding: FragmentGalleryBinding? = null | ||
private val binding: FragmentGalleryBinding | ||
get() = requireNotNull(_binding) |
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.
모 기업 면접에서 지적받았는데, requireNotNull을 사용한 코드들이 종종 보이던데 왜 쓰냐고 물어봤습니다. 저는 그게 null 처리에 만능이라고 생각했었다고, 근데 알고보니 아니었던 경험이 있었다고 말하고 면접을 이어나갔는데 영주님은 그런 과오에 빠지지 않았으면 좋겠어요. ㅎ.ㅎ value가 null이면 Exception을 throw한다는 것을 꼭 인지하고 사용하면 좋을 것 같아요. :-)
오오 감사합니다ㅏ
private var _binding: FragmentGalleryBinding? = null
private val binding: FragmentGalleryBinding
get() = requireNotNull(_binding) ?: throw IllegalArgumentException("fragment is 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.
음 원래 의도한 건 그런 느낌은 아니구요 ! requireNotNull의 value 자리에 null이 들어가면 IllegalArgumentException을 throw한다는 것을 알고 쓰면 좋을 것 같다는 얘기였습니다 !
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
} |
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.
onViewCreated가 딱히 하는 일이 없어보입니다 :-/
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.
onViewCreated가 딱히 하는 일이 없어보입니다 :-/
ㅎㅎ 홈은 지웠는데 이놈을 깜빡했네유
override fun getItemViewType(position: Int): Int { | ||
return when (position) { | ||
0 -> HEADER | ||
else -> BODY | ||
} | ||
} |
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.
오 ... bb
BodyViewHolder(itemHomeBodyBinding) | ||
} | ||
else -> { | ||
throw RuntimeException("알 수 없는 viewType error") |
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.
throw Exception
을 할 경우에는 이렇게 명확하게 msg를 전달하거나 혹은 적절한 타입의 Exception을 쓰는 게 좋은 것 같습니다. 음 저라면 IllegalArgumentException
도 고려해볼 것 같아요
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.
throw Exception
을 할 경우에는 이렇게 명확하게 msg를 전달하거나 혹은 적절한 타입의 Exception을 쓰는 게 좋은 것 같습니다. 음 저라면IllegalArgumentException
도 고려해볼 것 같아요
IllegalArgumentException
고려해볼게요!!
|
||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { | ||
if (holder is BodyViewHolder) { | ||
holder.onBind(repoList[position]) |
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.
이렇게 되면 1번째 ViewHolder(0번째 BodyViewHolder)에 repoList의 1번 아이템이 들어가지 않나요? 뭔가 유의하면서 코드를 작성해야 할 것 같네요 !
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.
이렇게 되면 1번째 ViewHolder(0번째 BodyViewHolder)에 repoList의 1번 아이템이 들어가지 않나요? 뭔가 유의하면서 코드를 작성해야 할 것 같네요 !
아 이게 여기에서 발생한 거군요.. 찾아주셔서 감사합니다ㅠㅠ 다시 작성해볼게요
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.
goooooooooood
<string name="home">홈</string> | ||
<string name="gallery">갤러리</string> | ||
<string name="search">검색</string> | ||
|
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.
1주차 과제부터 궁금했던 건데 이거는 왜 따로 적어주는 건가요? 다들 이렇게 쓰시더라구요
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.
1주차 과제부터 궁금했던 건데 이거는 왜 따로 적어주는 건가요? 다들 이렇게 쓰시더라구요
string을 따로 지정해준다면, 기획에서 ux라이팅 변경시에 이 string값만 변경해주면 되기 때문입니다!
android:layout_height="wrap_content" | ||
android:layout_marginTop="12dp" | ||
android:layout_marginBottom="12dp" | ||
android:maxLines="1" |
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.
오!! 텍스트가 몇 줄까지 가능한지도 설정할 수 있네요! 배워갑니다
setOnItemReselectedListener 이렇게 쓰는 게 맞는지..