Skip to content

Fix/209 코스발견 상단 배너 스크롤 타이머 로직 수정2 - #210

Merged
Larry7939 merged 2 commits into
developfrom
fix/209-코스발견-상단-배너-스크롤-타이머-로직-수정2
Aug 20, 2023

Hidden character warning

The head ref may contain hidden characters: "fix/209-\ucf54\uc2a4\ubc1c\uacac-\uc0c1\ub2e8-\ubc30\ub108-\uc2a4\ud06c\ub864-\ud0c0\uc774\uba38-\ub85c\uc9c1-\uc218\uc8152"
Merged

Fix/209 코스발견 상단 배너 스크롤 타이머 로직 수정2#210
Larry7939 merged 2 commits into
developfrom
fix/209-코스발견-상단-배너-스크롤-타이머-로직-수정2

Conversation

@Larry7939

Copy link
Copy Markdown
Contributor

📌 개요

#209 코스발견 상단 배너 스크롤 타이머 로직 수정2

✨ 작업 내용

상단 배너 초기화 로직인 setPromotion 메소드가 비대해짐에 따라 발생한 비효율적인 로직 개선
배너 자동 스크롤에 사용되는 timer 및 timerTask의 초기화 관련 이슈 해결

  • 초기화 로직과 비즈니스 로직의 분리
  • 메소드 명 변경 setPromotion -> setPromotionBanner
  • timer 및 timerTask의 초기화 여부에 따른 예외처리
    번외 : Toast 메시지 표시가 UI Thread에서 이루어지도록 수정

 - 초기화 로직과 비즈니스 로직의 분리
- 메소드 명 변경 setPromotion -> setPromotionBanner
@Larry7939Larry7939 added the 지훈 🦊 지훈 담당 label Aug 19, 2023

@unam98unam98 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

고생했어!!!

Comment on lines -30 to +35
Toast.makeText(context,"장기간 미접속으로 인해 재로그인이 필요합니다.",Toast.LENGTH_LONG).show()
Handler(Looper.getMainLooper()).post{
Toast.makeText(context,context.getString(R.string.alert_need_to_re_sign),Toast.LENGTH_LONG).show()
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

override fun authenticate()가 백그라운드에서 도는 함수인가요?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

넵 맞습니다!

Comment on lines -49 to +48
private lateinit var promotionAdapter: DiscoverPromotionAdapter
private val promotionAdapter: DiscoverPromotionAdapter by lazy {
DiscoverPromotionAdapter(requireContext(), this)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lateinit var가 아닌 by lazy를 쓰신 특별한 이유가 있을까요?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

  1. 한 번 초기화된 promotionAdapter를 이후에도 재사용하는 것을 보장하기 위함입니다!
  2. adpater를 사용하는 과정에서 setBannerCount 등 순서에 민감한 로직들이 있기 때문에 리팩토링에 어려움을 겪었습니다. 그래서 promotionAdapter가 사용될 때에만 adapter를 초기화하도록 lazy를 사용하였습니다.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

초기화 여부를 확인하는 조건문을 넣어주는 것보다 이게 깔끔하긴 하겠네요. 좋네요!!

Comment on lines -261 to -267
private fun autoScrollStart() {
private fun setTimerTask() {
timerTask = object : TimerTask() {
override fun run() {
scrollHandler.post(scrollPageRunnable)
}
}
timer.schedule(timerTask, INTERVAL_TIME, INTERVAL_TIME)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

분리 좋네요~

Comment on lines -208 to +209
private fun setPromotion(vp: ViewPager2, vpList: MutableList<DiscoverPromotionItemDTO>) {
setPromotionAdapter(vpList)
setPromotionIndicator(vp)
private fun setPromotionBanner(vp: ViewPager2) {
setPromotionViewPager(vp)
setScrollHandler(vp)
setScrollHandler()
setScrollPageRunnable(vp)
setTimerTask()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

세부적으로 더 쪼개준만큼 어떤 구성요소들이 있는지 더 직관적으로 파악하기 쉽고 이번처럼 이슈가 생겼을 때 관리를 더 수월하게 해나갈 수 있을 것 같아서 좋네요

@Larry7939
Larry7939 merged commit 81a792e into developAug 20, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

지훈 🦊지훈 담당

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Larry7939@unam98