mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Fix keyboard issue on some Android devices.
This commit is contained in:
@@ -3,14 +3,26 @@ package org.thoughtcrime.securesms.giph.mp4
|
||||
import android.graphics.Canvas
|
||||
import androidx.core.view.children
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
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() {
|
||||
override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
||||
setParentRecyclerTranslationY(parent)
|
||||
|
||||
parent.children.map { parent.getChildViewHolder(it) }.filterIsInstance(GiphyMp4Playable::class.java).forEach {
|
||||
callback.updateVideoDisplayPositionAndSize(parent, it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setParentRecyclerTranslationY(parent: RecyclerView) {
|
||||
if (parent.childCount == 0 || parent.canScrollVertically(-1) || parent.canScrollVertically(1)) {
|
||||
parent.translationY = 0f
|
||||
} else {
|
||||
val childTop = parent.children.last().top
|
||||
parent.translationY = min(0, -childTop).toFloat()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user