Conversation
| oldItem: ExerciseItemInfo, | ||
| newItem: ExerciseItemInfo | ||
| ): Boolean { | ||
| return oldItem == newItem |
There was a problem hiding this comment.
객체의 고유 식별자를 정해서 비교해줘야할 것 같네요!
areItemsTheSame, areContentsTheSame 메서드가 무슨 차이인지 알아보시면 이해되실겁니당
| const val NOTICE_INFO_TYPE = 0 | ||
| const val DATE_EXERCISE_INFO_TYPE = 1 | ||
|
|
||
| val diffUtil = object : DiffUtil.ItemCallback<ExerciseItemInfo>() { |
There was a problem hiding this comment.
utli -> extension에 보시면 ItemDiffCallback 구현해둔거 있어서 그거 쓰셔도 될것 같습니다~
| private val _exerciseHistoryInfoList = ArrayList<ExerciseData.ExerciseItemInfo>() | ||
| val exerciseHistoryInfoList: MutableLiveData<ArrayList<ExerciseData.ExerciseItemInfo>> by lazy { | ||
| MutableLiveData<ArrayList<ExerciseData.ExerciseItemInfo>>() | ||
| } | ||
|
|
There was a problem hiding this comment.
우선 _exerciseHistoryInfoList는 사용되지 않는것 같네요.
그리고 밑에 exerciseHistoryInfo가 ExerciseData를 포함하는 UI 상태이기 때문에 추가적인 라이브데이터는 필요없을 것 같습니다!
| exerciseViewModel.exerciseHistoryInfoList.observe(binding.lifecycleOwner!!) { | ||
| adapter.submitList(it.toMutableList()) | ||
| } |
There was a problem hiding this comment.
| exerciseViewModel.exerciseHistoryInfoList.observe(binding.lifecycleOwner!!) { | |
| adapter.submitList(it.toMutableList()) | |
| } | |
| adapter.submitList(exerciseData.exerciseItemInfoList) |
이미 ExerciseData를 가지고 있는데 이렇게 하면 안되나요??
There was a problem hiding this comment.
우선 해당 로직은 관찰하는 로직이므로 따로 빼서 observeLiveData에 넣어주는 것이 일관성 있어보입니다 !
There was a problem hiding this comment.
그리고 준희님 말씀처럼 exerciseHistoryInfoList를 관찰해야 할까요!? 요건 저도 정확히 모르니 설명해주시면 감사하겠습니다 !
There was a problem hiding this comment.
추가적으로 Fragment에서 관찰하실 때에는 viewLifeCycleOwner를 사용해주는 것이 좋습니다. 그 이유까지 알아보면 더 좋을 것 같아요 ! 찾다가 잘 모르시겠으면 질문해주세요 ~~
giovannijunseokim
left a comment
There was a problem hiding this comment.
ListAdapter에 익숙해지시면 추후 RecyclerView를 작성할 때 훨씬 간편히 작성할 수 있습니다 ~! 화이팅 !
📌 관련 이슈
📷 screenshot
📝 Work Desciption
list adapter 사용해봤습니담
📚 Reference 혹은 궁금한 사항들
list adapter 열심히 공부해봤는데 이론 읽을 때랑 적용할 때랑 ㅎ... 적용이 생각이랑 다르네요 맞는지 모르겠습니다 😅
뭔가 아닌 것 같은 부분이 두 곳 있는데, 눈 감고 그냥 올렸습니다..
궁금한 점: 운동모아보기 뷰에서 받는 데이터가 변경이 생기는 경우는 사용자가 미션을 완료했을 때와 날짜가 바뀔 때 인 것 같은데, recyclerview adapter가 아닌 list adapter를 사용하면 성능 향상이 클까요?