fix(creator): 커뮤니티 탭 하단 재평가를 보정한다
This commit is contained in:
@@ -493,9 +493,10 @@ class CreatorChannelActivity :
|
||||
|
||||
override fun onCreatorChannelLiveContentChanged() {
|
||||
updateCreatorChannelTabViewportHeight()
|
||||
updateViewPagerHeight()
|
||||
updateViewPagerHeight {
|
||||
postCheckCreatorChannelCurrentTabNeedsMore()
|
||||
}
|
||||
}
|
||||
|
||||
override fun isCreatorChannelOwner(): Boolean = currentHeader?.isOwner == true
|
||||
|
||||
@@ -505,9 +506,10 @@ class CreatorChannelActivity :
|
||||
|
||||
override fun onCreatorChannelAudioContentChanged() {
|
||||
updateCreatorChannelTabViewportHeight()
|
||||
updateViewPagerHeight()
|
||||
updateViewPagerHeight {
|
||||
postCheckCreatorChannelCurrentTabNeedsMore()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreatorChannelSeriesClicked(seriesId: Long) {
|
||||
startActivity(
|
||||
@@ -519,14 +521,16 @@ class CreatorChannelActivity :
|
||||
|
||||
override fun onCreatorChannelSeriesContentChanged() {
|
||||
updateCreatorChannelTabViewportHeight()
|
||||
updateViewPagerHeight()
|
||||
updateViewPagerHeight {
|
||||
postCheckCreatorChannelCurrentTabNeedsMore()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreatorChannelCommunityContentChanged() {
|
||||
updateViewPagerHeight()
|
||||
updateViewPagerHeight {
|
||||
postCheckCreatorChannelCurrentTabNeedsMore()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreatorChannelCommunityOwnerMoreClicked(item: CreatorChannelCommunityPostUiModel) {
|
||||
CreatorCommunityPostMenuBottomSheetDialog(
|
||||
@@ -894,23 +898,28 @@ class CreatorChannelActivity :
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateViewPagerHeight() {
|
||||
private fun updateViewPagerHeight(afterHeightUpdated: (() -> Unit)? = null) {
|
||||
updateCreatorChannelTabViewportHeight()
|
||||
binding.viewPager.post {
|
||||
val recyclerView = binding.viewPager.getChildAt(0) as? RecyclerView ?: return@post
|
||||
val currentPage = recyclerView.layoutManager?.findViewByPosition(binding.viewPager.currentItem) ?: return@post
|
||||
val recyclerView = binding.viewPager.getChildAt(0) as? RecyclerView
|
||||
val currentPage = recyclerView?.layoutManager?.findViewByPosition(binding.viewPager.currentItem)
|
||||
if (currentPage == null) {
|
||||
afterHeightUpdated?.invoke()
|
||||
return@post
|
||||
}
|
||||
val widthSpec = MeasureSpec.makeMeasureSpec(binding.viewPager.width, MeasureSpec.EXACTLY)
|
||||
val heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
|
||||
currentPage.measure(widthSpec, heightSpec)
|
||||
val measuredHeight = currentPage.measuredHeight
|
||||
val viewPagerVerticalPadding = binding.viewPager.paddingTop + binding.viewPager.paddingBottom
|
||||
val targetHeight = measuredHeight + viewPagerVerticalPadding
|
||||
if (measuredHeight <= 0 || binding.viewPager.layoutParams.height == targetHeight) return@post
|
||||
|
||||
if (measuredHeight > 0 && binding.viewPager.layoutParams.height != targetHeight) {
|
||||
binding.viewPager.updateLayoutParams {
|
||||
height = targetHeight
|
||||
}
|
||||
}
|
||||
afterHeightUpdated?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateCreatorChannelTabViewportHeight() {
|
||||
@@ -941,12 +950,13 @@ class CreatorChannelActivity :
|
||||
if (!isCreatorChannelLoadMoreTab(binding.viewPager.currentItem)) return
|
||||
|
||||
val contentHeight = binding.nestedScrollView.getChildAt(0)?.height ?: return
|
||||
val threshold = CREATOR_CHANNEL_LOAD_MORE_THRESHOLD_DP.dpToPx().toInt()
|
||||
val remainingScroll = calculateCreatorChannelRemainingScroll(
|
||||
contentHeight = contentHeight,
|
||||
viewportHeight = binding.nestedScrollView.height,
|
||||
scrollY = binding.nestedScrollView.scrollY
|
||||
)
|
||||
if (remainingScroll <= 0) {
|
||||
if (remainingScroll <= threshold) {
|
||||
notifyCurrentCreatorChannelTabScrolledToBottom()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ class CreatorChannelActivitySourceTest {
|
||||
assertTrue(source.contains("override fun onDestroy()"))
|
||||
assertTrue(source.contains("tabLayoutMediator?.detach()"))
|
||||
assertTrue(source.contains("binding.viewPager.unregisterOnPageChangeCallback(callback)"))
|
||||
assertTrue(source.contains("private fun updateViewPagerHeight()"))
|
||||
assertTrue(source.contains("private fun updateViewPagerHeight(afterHeightUpdated: (() -> Unit)? = null)"))
|
||||
assertTrue(source.contains("findViewByPosition(binding.viewPager.currentItem)"))
|
||||
assertTrue(source.contains("currentPage.measure(widthSpec, heightSpec)"))
|
||||
assertTrue(source.contains("binding.viewPager.updateLayoutParams"))
|
||||
@@ -394,7 +394,7 @@ class CreatorChannelActivitySourceTest {
|
||||
)
|
||||
)
|
||||
assertTrue(source.contains("val targetHeight = measuredHeight + viewPagerVerticalPadding"))
|
||||
assertTrue(source.contains("binding.viewPager.layoutParams.height == targetHeight"))
|
||||
assertTrue(source.contains("binding.viewPager.layoutParams.height != targetHeight"))
|
||||
assertTrue(source.contains("height = targetHeight"))
|
||||
assertFalse(source.contains("binding.viewPager.layoutParams.height == measuredHeight"))
|
||||
assertFalse(source.contains("height = measuredHeight"))
|
||||
@@ -464,6 +464,8 @@ class CreatorChannelActivitySourceTest {
|
||||
assertTrue(source.contains("findCommunityFragment()?.onCreatorChannelCommunityScrolledToBottom()"))
|
||||
assertTrue(source.contains("position == CreatorChannelTab.Community.ordinal"))
|
||||
assertTrue(source.contains("override fun onCreatorChannelCommunityContentChanged()"))
|
||||
assertTrue(source.contains("private fun updateViewPagerHeight(afterHeightUpdated: (() -> Unit)? = null)"))
|
||||
assertTrue(source.contains("updateViewPagerHeight {\n postCheckCreatorChannelCurrentTabNeedsMore()"))
|
||||
assertTrue(source.contains("findCommunityFragment()?.onCreatorChannelCommunityOwnerCtaVisibilityChanged("))
|
||||
assertTrue(source.contains("ownerCtaTab == CreatorChannelTab.Community"))
|
||||
assertTrue(source.contains("CreatorChannelTab.Community.ordinal -> CreatorChannelTab.Community"))
|
||||
@@ -1090,6 +1092,9 @@ class CreatorChannelActivitySourceTest {
|
||||
assertTrue(source.contains("private fun postCheckCreatorChannelCurrentTabNeedsMore()"))
|
||||
assertTrue(source.contains("binding.nestedScrollView.post"))
|
||||
assertTrue(source.contains("checkCreatorChannelCurrentTabNeedsMore()"))
|
||||
assertTrue(source.contains("afterHeightUpdated?.invoke()"))
|
||||
assertTrue(source.contains("val threshold = CREATOR_CHANNEL_LOAD_MORE_THRESHOLD_DP.dpToPx().toInt()"))
|
||||
assertTrue(source.contains("if (remainingScroll <= threshold)"))
|
||||
assertTrue(source.contains("if (!isCreatorChannelLoadMoreTab(binding.viewPager.currentItem)) return"))
|
||||
assertTrue(source.contains("findLiveFragment()?.onCreatorChannelLiveScrolledToBottom()"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user