Conversation
yangjiae12
approved these changes
Oct 12, 2025
| fun bind(album: Album){ | ||
| binding.homeTodayAlbumTitleTv.text = album.title | ||
| binding.homeTodayAlbumSingerTv.text = album.singer | ||
| binding.homeTodayAlbumIv.setImageResource(album.coverImg!!) |
Member
There was a problem hiding this comment.
널 강제 언래핑을 하면 NPE 위험이 있으니까 모델을 Int로 보장하거나 플레이스 홀더 처리를 고려해 봐도 좋을 것 같습니다!
Comment on lines
+43
to
+48
| override fun onBindViewHolder(holder: AlbumRVAdapter.ViewHolder, position: Int) { | ||
| holder.bind(albumlist[position]) | ||
| holder.itemView.setOnClickListener { mItemClickListener.onItemClick(albumlist[position]) } | ||
| holder.binding.homeTodayAlbumArrowIv.setOnClickListener { sendMiniPlayer.changeText(albumlist[position]) } | ||
| // holder.binding.homeTodayAlbumTitleTv.setOnClickListener { mItemClickListner.onRemoveAlbum(position) } | ||
| } |
Member
There was a problem hiding this comment.
현재 클릭 리스너가 bind() 함수 내부에 설정되어 있는데, onBindViewHolder가 호출되어 bind()가 실행될 때마다, 즉 아이템이 화면에 나타날 때마다 리스너 객체를 새로 생성하여 설정하게 되고 이로 인해 불필요한 객체를 생성하게 된다고 생각합니다. 따라서 ViewHolder의 init 블록을 사용하여 클릭 리스너를 한 번만 설정하면 좋을 것 같습니다.
Comment on lines
+20
to
+23
| fun removeitem(position: Int){ | ||
| albumlist.removeAt(position) | ||
| notifyDataSetChanged() | ||
| } |
Member
There was a problem hiding this comment.
현재 notifyDataSetChanged()를 통한 전체 갱신을 하고 있는데, addItem, removeItem에서 전체 갱신은 성능 저하를 유발할 수도 있기 때문에, notifyItemInserted(lastIndex), notifyItemRemoved(position)로 바꾸어 부분 갱신을 사용하는 것을 고려해 봐도 좋을 것 같습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 PR 제목
4주차 미션 제출 : FLO 클론 코딩
✅ 변경 사항
📷 영상 및 스크린샷
로직 실행 사진
🔗 알게 된 사항
RecyclerView를 이용하는 방법과 interface를 이용하는 방법에 대하여 알 수 있었습니다.
📝 질문 사항
콜백에 대하여 더 알아보고 싶어요