Skip to content
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

Closed
wants to merge 11 commits into from
Closed

Seminar2 필수과제 #9

wants to merge 11 commits into from

Conversation

2zerozu
Copy link
Contributor

@2zerozu 2zerozu commented Oct 10, 2022

setOnItemReselectedListener 이렇게 쓰는 게 맞는지..

@2zerozu 2zerozu requested a review from a team October 10, 2022 20:38
@2zerozu 2zerozu self-assigned this Oct 10, 2022
@2zerozu 2zerozu linked an issue Oct 10, 2022 that may be closed by this pull request
private val binding: ItemHomeHeaderBinding
) : RecyclerView.ViewHolder(binding.root)

companion object {

Choose a reason for hiding this comment

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

good

Copy link

@hansh0101 hansh0101 left a 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)

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한다는 것을 꼭 인지하고 사용하면 좋을 것 같아요. :-)
image

Copy link
Contributor Author

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한다는 것을 꼭 인지하고 사용하면 좋을 것 같아요. :-) image

오오 감사합니다ㅏ

private var _binding: FragmentGalleryBinding? = null
private val binding: FragmentGalleryBinding
    get() = requireNotNull(_binding) ?: throw IllegalArgumentException("fragment is null")

요로코롬 쓰면 되겠죠?

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한다는 것을 알고 쓰면 좋을 것 같다는 얘기였습니다 !

Comment on lines +24 to +26
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}

Choose a reason for hiding this comment

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

onViewCreated가 딱히 하는 일이 없어보입니다 :-/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

onViewCreated가 딱히 하는 일이 없어보입니다 :-/

ㅎㅎ 홈은 지웠는데 이놈을 깜빡했네유

Comment on lines +14 to +19
override fun getItemViewType(position: Int): Int {
return when (position) {
0 -> HEADER
else -> BODY
}
}

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")

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도 고려해볼 것 같아요

Copy link
Contributor Author

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])

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번 아이템이 들어가지 않나요? 뭔가 유의하면서 코드를 작성해야 할 것 같네요 !

Copy link
Contributor Author

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번 아이템이 들어가지 않나요? 뭔가 유의하면서 코드를 작성해야 할 것 같네요 !

아 이게 여기에서 발생한 거군요.. 찾아주셔서 감사합니다ㅠㅠ 다시 작성해볼게요

Copy link

@hajeong67 hajeong67 left a 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>

Choose a reason for hiding this comment

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

1주차 과제부터 궁금했던 건데 이거는 왜 따로 적어주는 건가요? 다들 이렇게 쓰시더라구요

Copy link
Contributor Author

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"

Choose a reason for hiding this comment

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

오!! 텍스트가 몇 줄까지 가능한지도 설정할 수 있네요! 배워갑니다

@2zerozu 2zerozu closed this Nov 19, 2022
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.

Seminar2 필수과제
4 participants