mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Fix pool limits and y-translation issues with CFv2 recycler view.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.giph.mp4
|
||||
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Rect
|
||||
import androidx.core.view.children
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.thoughtcrime.securesms.conversation.ConversationAdapter
|
||||
@@ -27,18 +28,28 @@ class GiphyMp4ItemDecoration(
|
||||
parent.translationY = 0f
|
||||
onRecyclerVerticalTranslationSet(parent.translationY)
|
||||
} else {
|
||||
val footerViewHolder = parent.children
|
||||
val threadHeaderViewHolder = parent.children
|
||||
.map { parent.getChildViewHolder(it) }
|
||||
.filter { it is ConversationAdapter.FooterViewHolder || it is ConversationAdapterV2.ThreadHeaderViewHolder }
|
||||
.firstOrNull()
|
||||
|
||||
if (footerViewHolder == null) {
|
||||
if (threadHeaderViewHolder == null) {
|
||||
parent.translationY = 0f
|
||||
onRecyclerVerticalTranslationSet(parent.translationY)
|
||||
return
|
||||
}
|
||||
|
||||
val childTop: Int = footerViewHolder.itemView.top
|
||||
val toolbarMargin = if (threadHeaderViewHolder is ConversationAdapterV2.ThreadHeaderViewHolder) {
|
||||
// A decorator adds the margin for the toolbar, margin is difference of the bounds "height" and the view height
|
||||
val bounds = Rect()
|
||||
parent.getDecoratedBoundsWithMargins(threadHeaderViewHolder.itemView, bounds)
|
||||
bounds.bottom - bounds.top - threadHeaderViewHolder.itemView.height
|
||||
} else {
|
||||
// Deprecated not needed for CFv2
|
||||
0
|
||||
}
|
||||
|
||||
val childTop: Int = threadHeaderViewHolder.itemView.top - toolbarMargin
|
||||
parent.translationY = min(0, -childTop).toFloat()
|
||||
onRecyclerVerticalTranslationSet(parent.translationY)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user