Closed Choe-Ji-Hwan closed 1 year ago
아래와 같이 스냅샷을 찍어서 list의 변화가 있다는 것을 주는 것이 어색하긴합니다만, 기능적으로는 잘 돌아가서 일단 먼저 이렇게 구현한 다음 리팩토링 할 예정입니다. [snapshot](https://developer.android.com/reference/kotlin/androidx/paging/PagingDataAdapter#snapshot())() Returns a new ItemSnapshotList representing the currently presented items 라는 의미로, 현재 보여지는 items 들 만 가져와서, 아마도 메모리 누수는 그렇게 많이 일어나지 않을거라 생각합니다. 해석을 잘못했다면 알려주세요 😸
list
private fun selectMoment(moment: MomentModel) { val data = momentPagingAdapter.snapshot().items.toMutableList() val changeData = data.map { snapShotMoment -> if (moment.id == snapShotMoment.id) { snapShotMoment.copy(isSelected = snapShotMoment.isSelected.not()) } else { snapShotMoment } }.toList() lifecycleScope.launch { viewModel.moments.collectLatest { momentPagingAdapter.submitData(PagingData.from(changeData)) } } }
🚀 Issue #67
👨🔧 개요
📝 작업 내용
📢 특이 사항
아래와 같이 스냅샷을 찍어서
list
의 변화가 있다는 것을 주는 것이 어색하긴합니다만, 기능적으로는 잘 돌아가서 일단 먼저 이렇게 구현한 다음 리팩토링 할 예정입니다. [snapshot](https://developer.android.com/reference/kotlin/androidx/paging/PagingDataAdapter#snapshot())() Returns a new ItemSnapshotList representing the currently presented items 라는 의미로, 현재 보여지는 items 들 만 가져와서, 아마도 메모리 누수는 그렇게 많이 일어나지 않을거라 생각합니다. 해석을 잘못했다면 알려주세요 😸