mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 03:58:48 +00:00
Fix swipe to reply positioning in CIV2.
This commit is contained in:
@@ -35,7 +35,11 @@ class V2ConversationItemLayout @JvmOverloads constructor(
|
|||||||
onMeasureListeners.forEach { it.onPreMeasure() }
|
onMeasureListeners.forEach { it.onPreMeasure() }
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||||
|
|
||||||
val remeasure = onMeasureListeners.map { it.onPostMeasure() }.any { it }
|
var remeasure = false
|
||||||
|
onMeasureListeners.forEach {
|
||||||
|
remeasure = it.onPostMeasure() || remeasure
|
||||||
|
}
|
||||||
|
|
||||||
if (remeasure) {
|
if (remeasure) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,17 +112,17 @@ open class V2ConversationItemTextOnlyViewHolder<Model : MappingModel<Model>>(
|
|||||||
override fun onPreMeasure() = Unit
|
override fun onPreMeasure() = Unit
|
||||||
|
|
||||||
override fun onPostMeasure(): Boolean {
|
override fun onPostMeasure(): Boolean {
|
||||||
val wrapperHeight = binding.bodyWrapper.measuredHeight
|
|
||||||
val yTranslation = (wrapperHeight - 38.dp) / 2f
|
|
||||||
binding.reply.translationY = -yTranslation
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
binding.root.addOnMeasureListener(footerDelegate)
|
binding.root.addOnMeasureListener(footerDelegate)
|
||||||
binding.root.addOnMeasureListener(replyDelegate)
|
binding.bodyWrapper.addOnLayoutChangeListener { _, _, top, _, bottom, _, _, _, _ ->
|
||||||
|
val wrapperHeight = bottom - top
|
||||||
|
val yTranslation = (wrapperHeight - 38.dp) / 2f
|
||||||
|
binding.reply.translationY = -yTranslation
|
||||||
|
}
|
||||||
|
|
||||||
binding.root.onDispatchTouchEventListener = dispatchTouchEventListener
|
binding.root.onDispatchTouchEventListener = dispatchTouchEventListener
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user