Fix reaction shade on new conversations.

This commit is contained in:
Alex Hart
2021-11-03 13:13:50 -03:00
committed by Greyson Parrelli
parent dc22b27cd8
commit 09dd2583b9
3 changed files with 27 additions and 5 deletions

View File

@@ -9,7 +9,10 @@ import kotlin.math.min
/**
* Decoration that will make the video display params update on each recycler redraw.
*/
class GiphyMp4ItemDecoration(val callback: GiphyMp4PlaybackController.Callback) : RecyclerView.ItemDecoration() {
class GiphyMp4ItemDecoration(
val callback: GiphyMp4PlaybackController.Callback,
val onRecyclerVerticalTranslationSet: (Float) -> Unit
) : RecyclerView.ItemDecoration() {
override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
setParentRecyclerTranslationY(parent)
@@ -21,6 +24,7 @@ class GiphyMp4ItemDecoration(val callback: GiphyMp4PlaybackController.Callback)
private fun setParentRecyclerTranslationY(parent: RecyclerView) {
if (parent.childCount == 0 || parent.canScrollVertically(-1) || parent.canScrollVertically(1)) {
parent.translationY = 0f
onRecyclerVerticalTranslationSet(parent.translationY)
} else {
val footerViewHolder = parent.children
.map { parent.getChildViewHolder(it) }
@@ -29,12 +33,13 @@ class GiphyMp4ItemDecoration(val callback: GiphyMp4PlaybackController.Callback)
if (footerViewHolder == null) {
parent.translationY = 0f
onRecyclerVerticalTranslationSet(parent.translationY)
return
}
val childTop = footerViewHolder.itemView.top
parent.translationY = min(0, -childTop).toFloat().also {
}
parent.translationY = min(0, -childTop).toFloat()
onRecyclerVerticalTranslationSet(parent.translationY)
}
}
}