Skip to content

Conversation

@leeeha
Copy link
Member

@leeeha leeeha commented Dec 13, 2023

📌 개요

✨ 작업 내용

  • 뷰페이저 무한 스크롤
  • 인디케이터 같이 움직이도록
  • 뷰페이저 스크롤 상태에 따라 Job 조정하기
  • 상세페이지 갔다가 메인 돌아왔을 때 제목, 스크랩 변경사항 바로 반영하기 (아직 진행 중)

✨ PR 포인트

코루틴의 delay 함수와 Job 객체의 생성/취소를 이용하여, 배너가 수평으로 무한 스크롤 되도록 구현했습니다!

이 블로그에 나와있는 방법을 많이 참고했어요!

배너가 항상 같은 방향으로 스크롤 되어야 하기 때문에, 초기 위치를 Int.MAX_VALUE / 2 로 잡고 시간에 따라 또는 사용자의 터치 이벤트에 따라 뷰페이저 position이 +/- 되는 방식으로 구현했어요!

코드 보다가 이해가 안 되는 부분은 질문 남겨주세요!!

unam98 and others added 11 commits December 9, 2023 12:24
- IDLE 상태: 딜레이 시간을 주며 뷰페이저를 스크롤 하는 Job 생성하기
- DRAGGING 상태: 기존에 생성된 Job 취소하기
…hub.com/Runnect/Runnect-Android into feature/refactor-discover-banner-viewpager

� Conflicts:
�	app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt
- 상세 화면에서 바뀔 수 있는 데이터는 EditableDiscoverCourse 데이터 클래스로 정의
- 액티비티 Result API 사용하여 상세 화면에서 메인 화면으로 데이터 클래스 전달
- 멀티뷰 어댑터에서 아이템 내용 바꾸는 함수 실행
@leeeha leeeha self-assigned this Dec 13, 2023
@leeeha leeeha added 하은 🐰 하은 담당 REFACTOR 🧹 코드 리팩토링 labels Dec 13, 2023
[FIX] setOnlyAlertOnce 추가를 통한 소리/진동 제한
Copy link
Collaborator

@unam98 unam98 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다~! named argument 누락된 부분들 채워주시면 좋을 것 같아요!


private fun registerCallback() {
registerBackPressedCallback()
registerRefreshLayoutScrollUpCallback()
Copy link
Collaborator

Choose a reason for hiding this comment

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

더 읽기 쉽게 이 함수의 배치를 setupBannerGetStateObserver() 밑으로 옮겨주는 게 어떨까요? 추가로 named argument도 챙겨주시면 좋을 것 같습니다~!

putExtra(EXTRA_PUBLIC_COURSE_ID, publicCourseId)
putExtra(EXTRA_ROOT_SCREEN, CourseDetailRootScreen.COURSE_DISCOVER)
private fun initBannerViewPagerItemPosition() {
currentBannerPosition = Int.MAX_VALUE / 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

/2는 왜 하는 것인가요? 의미를 가진 숫자라면 상수화시키는 것이 어떨까요?

Copy link
Collaborator

Choose a reason for hiding this comment

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

뷰페이저의 초기 위치를 가운데에 두기 위함인 것 같아요 ! /2를 하지않으면 한 번 더 스크롤시 Int.MAX_VALUE 에서 바로 오버플로우가 발생해서 가운데에 두고 안전하게 무한 스크롤을 구현한 듯 합니다

Copy link
Member Author

Choose a reason for hiding this comment

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

넵 맞습니다!! 뷰페이저가 항상 같은 방향으로 스크롤 되도록 임의로 리스트 크기를 무한대로 잡고, 초기 위치는 가운데로 설정한 것입니다. 참고한 블로그 링크를 PR 올릴 때 같이 첨부했는데, 해당 글에서 자세한 내용 확인하실 수 있습니다!

private const val CENTER_POS_OF_INFINITE_BANNERS = Int.MAX_VALUE / 2

위와 같이 상수화 시킬 수 있을 거 같아요!

Copy link
Collaborator

@sxunea sxunea left a comment

Choose a reason for hiding this comment

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

발견하기 부분 전체적으로 읽어보느라 늦었네요 😭 여긴 배너를 파이어베이스에서 가져오는 줄 몰랐는데 덕분에 그 부분도 살펴봤습니다 ㅎㅎㅎ 고생했어용

putExtra(EXTRA_PUBLIC_COURSE_ID, publicCourseId)
putExtra(EXTRA_ROOT_SCREEN, CourseDetailRootScreen.COURSE_DISCOVER)
private fun initBannerViewPagerItemPosition() {
currentBannerPosition = Int.MAX_VALUE / 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

뷰페이저의 초기 위치를 가운데에 두기 위함인 것 같아요 ! /2를 하지않으면 한 번 더 스크롤시 Int.MAX_VALUE 에서 바로 오버플로우가 발생해서 가운데에 두고 안전하게 무한 스크롤을 구현한 듯 합니다

companion object {
private const val PAGE_NUM = 900
private const val INTERVAL_TIME = 5000L
private const val BANNER_SCROLL_DELAY_TIME = 3000L
Copy link
Collaborator

Choose a reason for hiding this comment

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

BANNER_SCROLL_DELAY_TIME 의 값은 그냥 적당한 시간으로 정해두신건가요? (궁금증)

Copy link
Member Author

Choose a reason for hiding this comment

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

이와 관련된 기능 명세가 있는지 이제야 확인해봤는데 기존 코드대로 5초로 설정해야 될 거 같습니다! 디테일한 확인 넘 감사드려요 😄

Comment on lines +392 to 395
private fun checkRefreshPossibleCondition(): Boolean {
val layoutManager = binding.rvDiscoverMultiView.layoutManager as LinearLayoutManager
return layoutManager.findFirstCompletelyVisibleItemPosition() > 0
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Copy link
Member

@dongx0915 dongx0915 left a comment

Choose a reason for hiding this comment

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

굿굿 고생하셨습니다~👍

@leeeha leeeha merged commit 55b4ded into develop Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

REFACTOR 🧹 코드 리팩토링 하은 🐰 하은 담당

Projects

Development

Successfully merging this pull request may close these issues.

[REFACTOR] 코스 발견 / 프로모션 배너 뷰페이저 애니메이션

5 participants