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

[feat] 위니피드, 마이피드 / Paging3 적용 + 로딩 프로그레스바 구현 #108

Merged
merged 24 commits into from
Aug 14, 2023

Conversation

sxunea
Copy link
Contributor

@sxunea sxunea commented Aug 11, 2023

📝 Work Description

  • 피드에 paging3 적용
  • 페이지 사이에 로딩 프로그레스바 구현
  • 좋아요,삭제 등 기존 로직 페이징, 소셜로그인에 맞게 수정

📣 To Reviewers

  • 내일 오후까지 리뷰해주시면 감사하겠습니다 :)
  • 구현방법을 여러가지로 해보느라 커밋별로 보기보단 전체변경사항으로 바꿔서 보는걸 추천드립니다
  • 로딩 바 무슨색 할까요

…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
…ding progress bar 구현" - 방식 변경 위해 revert

This reverts commit 945290f.
@sxunea sxunea requested review from leeeha and Sangwook123 and removed request for leeeha August 11, 2023 20:43
@sxunea sxunea self-assigned this Aug 11, 2023
@sxunea sxunea added feat ✨ 새로운 기능 구현 혜선 🐱 labels Aug 11, 2023
@sxunea sxunea added this to the 기능 구현 ✨ milestone Aug 11, 2023
@sxunea
Copy link
Contributor Author

sxunea commented Aug 11, 2023

기록용 : 페이징된 recyclerview에 페이지 끝마다 로딩 프로그레스바 넣기

  1. 다이얼로그로 표현 (2440b52)
  2. MultiviewType ViewHolder + 추상화 + type으로 로딩 파악 (945290f) (e72dce8)
  3. loadState에 따라 visibility 조절
  4. loadStateAdapter 도입, addLoadStateListener 이용해 탐지 (ff6ddf1) (535cfdc) -> 최종 !

Copy link
Member

@leeeha leeeha left a 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
Copy link
Member

Choose a reason for hiding this comment

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

저희 패키지 컨벤션 문서 보면, 패키지 네임은 모두 소문자로 작성한다고 되어있어요! source 패키지 아래에 있으니까 paging 만 적어도 괜찮을 거 같습니다 :)

Copy link
Contributor Author

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)
}
Copy link
Member

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)
Copy link
Member

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")
Copy link
Member

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()
}
Copy link
Member

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 {
Copy link
Member

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) {
Copy link
Member

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 ->
Copy link
Member

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 ->
Copy link
Member

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" />
Copy link
Member

Choose a reason for hiding this comment

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

로딩 프로그레스바 색상은,, 인스타처럼 그레이 색상 어떨까요?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

눈물머금고 형광노랑 보내줍니다 ,,, ❤️

}
notifyItemChanged(index)
}
}

Copy link
Member

Choose a reason for hiding this comment

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

여기 아래 코드에서 궁금한 점이 있는데요! DiffUtil.ItemCallbackareItemsTheSame 함수를 오버라이딩 할 때는 두 객체가 동일한지 비교하게 되는데, 이때 보통 아이템을 유일하게 식별할 수 있는 id 값이나 === 연산자로 주소 값을 비교하는 거 같아요! 그런데 아래 코드에서 feedId 가 아니라, isLiked 로 WineyFeed 아이템을 식별한 이유가 있을까요??

만약 areItemsTheSame를 잘못 정의하면 모든 Item을 다 지우고 새 아이템을 Insert 하게 되므로, 기존의 notifyDataSetChanged()와 다를 것이 없어지기 때문에 주의해야 한다고 해요!

참고) https://jminie.tistory.com/146?category=1040997

Copy link
Contributor Author

Choose a reason for hiding this comment

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

어 마침 방금 푸쉬한거에 해당 부분 수정되어있습니다 ㅎㅎㅎ
앱잼기간에 좋아요 상태를 반영할때 해봤던건데 수정이안되어있었네요 ... ! 감사합니다 👍

@sxunea sxunea requested a review from leeeha August 14, 2023 16:48
Copy link
Member

@leeeha leeeha left a comment

Choose a reason for hiding this comment

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

어푸! LGTM 👍👍

@sxunea sxunea merged commit 0e389af into develop Aug 14, 2023
1 check passed
@sxunea sxunea deleted the feature/feat-feed-inifinitescroll branch August 14, 2023 16:59
wineyFeedLoadAdapter.loadState = loadState.refresh
checkAndSetEmptyLayout()
}
myFeedAdapter.submitData(state.data)
Copy link
Member

Choose a reason for hiding this comment

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

이 부분에서 뭔가 로직이 잘못 되었는지 '아직 없사옵니다' 이미지가 잠깐 나타났다 사라지는 이슈가 다시 발생하더라구요! 저번에 이 문제 때문에 Loading 상태에서 해당 로직을 처리했던 거 같은데, 확인 한번 부탁드려요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat ✨ 새로운 기능 구현 혜선 🐱
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[feat] 위니피드, 마이피드 / Paging3 적용, 로딩 인디케이터 구현
2 participants