-
Notifications
You must be signed in to change notification settings - Fork 0
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
[feat] 위니피드, 마이피드 / Paging3 적용 + 로딩 프로그레스바 구현 #108
Conversation
…inifinitescroll # Conflicts: # app/src/main/java/com/android/go/sopt/winey/data/repository/AuthRepositoryImpl.kt # app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt
This reverts commit e72dce8.
…ding progress bar 구현" - 방식 변경 위해 revert This reverts commit 945290f.
…inifinitescroll # Conflicts: # app/src/main/java/com/android/go/sopt/winey/data/repository/AuthRepositoryImpl.kt
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.
페이징, LoadStateAdapter, SwipeRefresh, API 분리까지 넘넘 고생많았어!!!
백혜선 폼 미쳐따~~~!!! 💘💘
@@ -0,0 +1,43 @@ | |||
package com.android.go.sopt.winey.data.source.pagingSource |
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.
저희 패키지 컨벤션 문서 보면, 패키지 네임은 모두 소문자로 작성한다고 되어있어요! source 패키지 아래에 있으니까 paging 만 적어도 괜찮을 거 같습니다 :)
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.
감사합니다 수정할게요 :)
return state.anchorPosition?.let { position -> | ||
state.closestPageToPosition(position)?.prevKey?.plus(1) | ||
?: state.closestPageToPosition(position)?.nextKey?.minus(1) | ||
} |
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.
중복되는 부분은 아래 코드처럼 변수를 만들어서 사용해도 좋을 듯 하네요!
return state.anchorPosition?.let { position ->
val anchorPage = state.closestPageToPosition(position)
anchorPage?.prevKey?.plus(1) ?: anchorPage?.nextKey?.minus(1)
}
|
||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, WineyFeed> { | ||
val position = params.key ?: STARTING_KEY | ||
if (position != STARTING_KEY) delay(DELAY_MILLIS) |
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.
상수화 👍
@Query("page") page: Int | ||
): ResponseGetWineyFeedListDto | ||
|
||
@GET("feed/myFeed") |
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.
오호 이 부분만 다르고, 위니피드, 마이피드 요청/응답 데이터는 모두 같은 타입이군요!
) : BasePagingSource(feedService) { | ||
override suspend fun getFeedList(position: Int): List<WineyFeed> { | ||
return feedService.getWineyFeedList(position).toWineyFeed() | ||
} |
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.
무분별한 상속은 지양해야 하지만, 지금은 중복되는 코드를 줄이기 위해 BaseXXX 을 사용하는 게 괜찮아 보입니다!
더 나은 다른 방식이 있는지는 좀 더 고민해봐야 할 거 같네요!
private fun initGetFeedStateObserver() { | ||
viewLifecycleOwner.lifecycleScope.launch { | ||
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { | ||
launch { |
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.
요기도 launch 블록으로 감싸지 않아도 될 거 같아요!
myFeedAdapter.submitData(state.data) | ||
myFeedAdapter.addLoadStateListener { loadState -> | ||
wineyFeedLoadAdapter.loadState = loadState.refresh | ||
if (loadState.append.endOfPaginationReached) { |
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.
오호 페이징의 endOfPaginationReached 이용하니까 좋네요!!
@@ -45,7 +48,7 @@ class MyFeedDeleteDialogFragment(private val feedId: Int, private val userLevel: | |||
} | |||
|
|||
private fun initDeleteFeedStateObserver() { | |||
myFeedViewModel.deleteMyFeedState.observe(viewLifecycleOwner) { state -> | |||
myFeedViewModel.deleteMyFeedState.flowWithLifecycle(viewLifeCycle).onEach { state -> |
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.
엇 여기서 launchIn() 함수를 블록 끝에 작성해줘야 되지 않을까요??
} | ||
} | ||
} | ||
|
||
private fun initPostLikeStateObserver() { | ||
viewModel.postMyFeedLikeState.observe(viewLifecycleOwner) { state -> | ||
viewModel.postMyFeedLikeState.flowWithLifecycle(viewLifeCycle).onEach { state -> |
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.
요기도 블록 끝에 launchIn 함수 호출해줘야 할 거 같아요!
android:layout_height="wrap_content" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> |
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.
로딩 프로그레스바 색상은,, 인스타처럼 그레이 색상 어떨까요?!
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.
눈물머금고 형광노랑 보내줍니다 ,,, ❤️
} | ||
notifyItemChanged(index) | ||
} | ||
} | ||
|
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.
여기 아래 코드에서 궁금한 점이 있는데요! DiffUtil.ItemCallback
의 areItemsTheSame
함수를 오버라이딩 할 때는 두 객체가 동일한지 비교하게 되는데, 이때 보통 아이템을 유일하게 식별할 수 있는 id 값이나 ===
연산자로 주소 값을 비교하는 거 같아요! 그런데 아래 코드에서 feedId 가 아니라, isLiked 로 WineyFeed 아이템을 식별한 이유가 있을까요??
만약 areItemsTheSame를 잘못 정의하면 모든 Item을 다 지우고 새 아이템을 Insert 하게 되므로, 기존의 notifyDataSetChanged()와 다를 것이 없어지기 때문에 주의해야 한다고 해요!
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.
어 마침 방금 푸쉬한거에 해당 부분 수정되어있습니다 ㅎㅎㅎ
앱잼기간에 좋아요 상태를 반영할때 해봤던건데 수정이안되어있었네요 ... ! 감사합니다 👍
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.
어푸! LGTM 👍👍
wineyFeedLoadAdapter.loadState = loadState.refresh | ||
checkAndSetEmptyLayout() | ||
} | ||
myFeedAdapter.submitData(state.data) |
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.
이 부분에서 뭔가 로직이 잘못 되었는지 '아직 없사옵니다' 이미지가 잠깐 나타났다 사라지는 이슈가 다시 발생하더라구요! 저번에 이 문제 때문에 Loading 상태에서 해당 로직을 처리했던 거 같은데, 확인 한번 부탁드려요!
📝 Work Description
📣 To Reviewers