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

[refactor] 운동모아보기 뷰 listadapter로 변경 #106

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

hyunjium
Copy link
Collaborator

@hyunjium hyunjium commented Mar 4, 2024

📌 관련 이슈

📷 screenshot

📝 Work Desciption

list adapter 사용해봤습니담

📚 Reference 혹은 궁금한 사항들

  • list adapter 열심히 공부해봤는데 이론 읽을 때랑 적용할 때랑 ㅎ... 적용이 생각이랑 다르네요 맞는지 모르겠습니다 😅

  • 뭔가 아닌 것 같은 부분이 두 곳 있는데, 눈 감고 그냥 올렸습니다..

  • 궁금한 점: 운동모아보기 뷰에서 받는 데이터가 변경이 생기는 경우는 사용자가 미션을 완료했을 때와 날짜가 바뀔 때 인 것 같은데, recyclerview adapter가 아닌 list adapter를 사용하면 성능 향상이 클까요?

@hyunjium hyunjium added Pull Request 🔥 pr 날릴때 현지 🐱 엄니 refactoring 리팩토링 labels Mar 4, 2024
@hyunjium hyunjium added this to the 2차 스프린트 milestone Mar 4, 2024
@hyunjium hyunjium self-assigned this Mar 4, 2024
Copy link
Contributor

@l2zh l2zh left a comment

Choose a reason for hiding this comment

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

엄니 화이팅!

oldItem: ExerciseItemInfo,
newItem: ExerciseItemInfo
): Boolean {
return oldItem == newItem
Copy link
Contributor

Choose a reason for hiding this comment

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

객체의 고유 식별자를 정해서 비교해줘야할 것 같네요!
areItemsTheSame, areContentsTheSame 메서드가 무슨 차이인지 알아보시면 이해되실겁니당

companion object {
const val NOTICE_INFO_TYPE = 0
const val DATE_EXERCISE_INFO_TYPE = 1

val diffUtil = object : DiffUtil.ItemCallback<ExerciseItemInfo>() {
Copy link
Contributor

Choose a reason for hiding this comment

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

utli -> extension에 보시면 ItemDiffCallback 구현해둔거 있어서 그거 쓰셔도 될것 같습니다~

Comment on lines +22 to +26
private val _exerciseHistoryInfoList = ArrayList<ExerciseData.ExerciseItemInfo>()
val exerciseHistoryInfoList: MutableLiveData<ArrayList<ExerciseData.ExerciseItemInfo>> by lazy {
MutableLiveData<ArrayList<ExerciseData.ExerciseItemInfo>>()
}

Copy link
Contributor

Choose a reason for hiding this comment

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

우선 _exerciseHistoryInfoList는 사용되지 않는것 같네요.
그리고 밑에 exerciseHistoryInfo가 ExerciseData를 포함하는 UI 상태이기 때문에 추가적인 라이브데이터는 필요없을 것 같습니다!

Comment on lines +82 to +84
exerciseViewModel.exerciseHistoryInfoList.observe(binding.lifecycleOwner!!) {
adapter.submitList(it.toMutableList())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
exerciseViewModel.exerciseHistoryInfoList.observe(binding.lifecycleOwner!!) {
adapter.submitList(it.toMutableList())
}
adapter.submitList(exerciseData.exerciseItemInfoList)

이미 ExerciseData를 가지고 있는데 이렇게 하면 안되나요??

Copy link
Collaborator

Choose a reason for hiding this comment

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

우선 해당 로직은 관찰하는 로직이므로 따로 빼서 observeLiveData에 넣어주는 것이 일관성 있어보입니다 !

Copy link
Collaborator

@giovannijunseokim giovannijunseokim Mar 6, 2024

Choose a reason for hiding this comment

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

그리고 준희님 말씀처럼 exerciseHistoryInfoList를 관찰해야 할까요!? 요건 저도 정확히 모르니 설명해주시면 감사하겠습니다 !

Copy link
Collaborator

Choose a reason for hiding this comment

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

추가적으로 Fragment에서 관찰하실 때에는 viewLifeCycleOwner를 사용해주는 것이 좋습니다. 그 이유까지 알아보면 더 좋을 것 같아요 ! 찾다가 잘 모르시겠으면 질문해주세요 ~~

Copy link
Collaborator

@giovannijunseokim giovannijunseokim left a comment

Choose a reason for hiding this comment

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

ListAdapter에 익숙해지시면 추후 RecyclerView를 작성할 때 훨씬 간편히 작성할 수 있습니다 ~! 화이팅 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pull Request 🔥 pr 날릴때 refactoring 리팩토링 현지 🐱 엄니
Projects
Status: 🏋️ In Progress
Development

Successfully merging this pull request may close these issues.

[refactor] recyclerview adapter를 list adapter로 변경
3 participants