-
Notifications
You must be signed in to change notification settings - Fork 0
[Mission] 4주차 미션제출 #44
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
base: Bongbak/main
Are you sure you want to change the base?
Conversation
탭 레이아웃 저장한 곡, 음악파일, 저장 앨범 프래그먼트 추가 및 연결 기능 구현
yangjiae12
left a comment
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.
4주차 미션 수고 많으셨습니다~! 다음부터는 커밋 컨벤션도 지켜서 작성해 주시면 좋을 것 같습니다
| // } | ||
| // binding.songSelectRandomIv.setOnClickListener { | ||
| // setRandomStatus(false) | ||
| // } |
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.
주석 자체를 삭제하여 코드를 간결하게 유지할 수 없고 보존할 필요가 있는 내용이라면 한줄 주석(//)이 아닌 블록 주석(/* */)을 활용하여 코드를 깔끔하게 관리해도 좋을 것 같습니다
| fun removeItem(position:Int){ | ||
| savedList.removeAt(position) | ||
| notifyItemRemoved(position) | ||
| notifyItemRangeChanged(position, savedList.size) | ||
| } | ||
|
|
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.
현재 removeItem()에서 연속으로 호출하고 있는데, notifyItemRemoved(position)만 호출해도 이후 아이템들의 위치가 자동으로 재계산되므로, 일반적으로 notifyItemRangeChanged()는 불필요합니다.
| holder.binding.itemSavedMore01Iv.setOnClickListener { | ||
| myItemClickListener.onRemoveItem(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.
현재 클릭 리스너가 bind() 함수 내부에 설정되어 있는데, onBindViewHolder가 호출되어 bind()가 실행될 때마다, 즉 아이템이 화면에 나타날 때마다 리스너 객체를 새로 생성하여 설정하게 되고 이로 인해 불필요한 객체를 생성하게 된다고 생각합니다. 따라서 ViewHolder의 init 블록을 사용하여 클릭 리스너를 한 번만 설정하면 좋을 것 같습니다.
📌 PR 제목
다시 수정해서 제대로 올렸습니다! 감사합니당
✅ 변경 사항
📷 영상 및 스크린샷