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