Skip to content

Commit

Permalink
[DEL] #282 추천 코스 무한 스크롤 관련 코드 삭제하기
Browse files Browse the repository at this point in the history
나중에 로직 다시 설계할 예정
  • Loading branch information
leeeha committed Dec 10, 2023
1 parent cbf70d6 commit ee227dd
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,6 @@ class DiscoverFragment : BindingFragment<FragmentDiscoverBinding>(R.layout.fragm
},
handleVisitorMode = {
context?.let { showCourseScrapWarningToast(it) }
},
currentPageNumber = viewModel.currentPageNumber,
onNextPageLoad = { pageNo ->
// todo: 다음 페이지 요청하고, 뷰 갱신하기
viewModel.getRecommendCourse(pageNo = pageNo, ordering = "date")
viewModel.updateCurrentPageNumber(pageNo)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class DiscoverViewModel @Inject constructor(

fun refreshCurrentCourses() {
getMarathonCourse()
getRecommendCourse(pageNo = currentPageNumber, ordering = "date")
getRecommendCourse(pageNo = 1, ordering = "date")
}

private fun getDiscoverBanners() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ class DiscoverMultiViewAdapter(
private val onHeartButtonClick: (Int, Boolean) -> Unit,
private val onCourseItemClick: (Int) -> Unit,
private val handleVisitorMode: () -> Unit,
private val currentPageNumber: Int,
private val onNextPageLoad: (Int) -> Unit,
) : RecyclerView.Adapter<DiscoverMultiViewHolder>() {

enum class MultiViewType {
MARATHON,
RECOMMEND
Expand Down Expand Up @@ -57,8 +54,7 @@ class DiscoverMultiViewAdapter(
),
onHeartButtonClick = onHeartButtonClick,
onCourseItemClick = onCourseItemClick,
handleVisitorMode = handleVisitorMode,
onNextPageLoad = onNextPageLoad
handleVisitorMode = handleVisitorMode
)
}
}
Expand All @@ -74,7 +70,7 @@ class DiscoverMultiViewAdapter(

is DiscoverMultiViewHolder.RecommendCourseViewHolder -> {
(multiViewItems[position] as? List<RecommendCourse>)?.let {
holder.bind(currentPageNumber, it)
holder.bind(it)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ sealed class DiscoverMultiViewHolder(binding: ViewDataBinding) :
private val onHeartButtonClick: (Int, Boolean) -> Unit,
private val onCourseItemClick: (Int) -> Unit,
private val handleVisitorMode: () -> Unit,
private val onNextPageLoad: (Int) -> Unit,

) : DiscoverMultiViewHolder(binding) {
fun bind(currentPageNumber: Int, recommendCourses: List<RecommendCourse>) {
fun bind(recommendCourses: List<RecommendCourse>) {
binding.rvDiscoverRecommend.apply {
setHasFixedSize(true)
layoutManager = GridLayoutManager(context, 2)
Expand All @@ -69,18 +67,14 @@ sealed class DiscoverMultiViewHolder(binding: ViewDataBinding) :
topSpaceSize = 20
)
)

initScrollListener(currentPageNumber, this)
}
}

private fun initScrollListener(currentPageNumber: Int, recyclerView: RecyclerView) {
recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)

// TODO: 스크롤이 최하단까지 내려간 경우, 다음 페이지 요청하기 (다음 페이지가 있는 경우에만)
//onNextPageLoad(currentPageNumber + 1)
}
})
}
Expand Down

0 comments on commit ee227dd

Please sign in to comment.