This commit is contained in:
Mariotaku Lee 2017-03-02 09:24:09 +08:00
parent cfbe29eb1f
commit d78f3dca96
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
3 changed files with 10 additions and 4 deletions

View File

@ -32,7 +32,7 @@ fun RecyclerView.LayoutManager.calculateSpaceItemHeight(child: View, spaceViewTy
if (typeToMeasure == spaceViewType) {
break
}
if (typeToMeasure == typeStart || heightBeforeSpace != 0) {
if (typeToMeasure == typeStart || heightBeforeSpace != 0 && child != childToMeasure) {
heightBeforeSpace += getDecoratedMeasuredHeight(childToMeasure)
}
}
@ -40,5 +40,5 @@ fun RecyclerView.LayoutManager.calculateSpaceItemHeight(child: View, spaceViewTy
val spaceHeight = recyclerView.measuredHeight - heightBeforeSpace
return Math.max(0, spaceHeight)
}
return getDecoratedMeasuredHeight(child)
return -1
}

View File

@ -1960,8 +1960,11 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
override fun getDecoratedMeasuredHeight(child: View): Int {
if (getItemViewType(child) == StatusAdapter.VIEW_TYPE_SPACE) {
return calculateSpaceItemHeight(child, StatusAdapter.VIEW_TYPE_SPACE,
val height = calculateSpaceItemHeight(child, StatusAdapter.VIEW_TYPE_SPACE,
StatusAdapter.VIEW_TYPE_DETAIL_STATUS)
if (height >= 0) {
return height
}
}
return super.getDecoratedMeasuredHeight(child)
}

View File

@ -668,7 +668,10 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
override fun getDecoratedMeasuredHeight(child: View): Int {
if (getItemViewType(child) == VIEW_TYPE_BOTTOM_SPACE) {
return calculateSpaceItemHeight(child, VIEW_TYPE_BOTTOM_SPACE, VIEW_TYPE_HEADER)
val height = calculateSpaceItemHeight(child, VIEW_TYPE_BOTTOM_SPACE, VIEW_TYPE_HEADER)
if (height >= 0) {
return height
}
}
return super.getDecoratedMeasuredHeight(child)
}