mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-08 09:18:39 +01:00
Wait for global layout before animating in bottom action bar.
This commit is contained in:
+8
-13
@@ -2283,9 +2283,7 @@ class ConversationFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
bottomActionBar.setItems(items)
|
bottomActionBar.setItems(items)
|
||||||
bottomActionBar.doAfterNextLayout {
|
setBottomActionBarVisibility(true)
|
||||||
setBottomActionBarVisibility(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setBottomActionBarVisibility(isVisible: Boolean) {
|
private fun setBottomActionBarVisibility(isVisible: Boolean) {
|
||||||
@@ -2300,24 +2298,21 @@ class ConversationFragment :
|
|||||||
|
|
||||||
val additionalScrollOffset = 54.dp
|
val additionalScrollOffset = 54.dp
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
ViewUtil.animateIn(bottomActionBar, bottomActionBar.enterAnimation)
|
bottomActionBar.visibility = View.INVISIBLE
|
||||||
container.hideInput()
|
|
||||||
inputPanel.setHideForSelection(true)
|
|
||||||
animationsAllowed = false
|
animationsAllowed = false
|
||||||
|
|
||||||
bottomActionBar.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener {
|
bottomActionBar.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
override fun onPreDraw(): Boolean {
|
override fun onGlobalLayout() {
|
||||||
if (bottomActionBar.measuredHeight == 0 && bottomActionBar.visible) {
|
bottomActionBar.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
bottomActionBar.viewTreeObserver.removeOnPreDrawListener(this)
|
ViewUtil.animateIn(bottomActionBar, bottomActionBar.enterAnimation)
|
||||||
|
container.hideInput()
|
||||||
|
inputPanel.setHideForSelection(true)
|
||||||
|
|
||||||
val bottomPadding = bottomActionBar.measuredHeight + ((bottomActionBar.layoutParams as? ViewGroup.MarginLayoutParams)?.bottomMargin ?: 18.dp)
|
val bottomPadding = bottomActionBar.measuredHeight + ((bottomActionBar.layoutParams as? ViewGroup.MarginLayoutParams)?.bottomMargin ?: 18.dp)
|
||||||
ViewUtil.setPaddingBottom(binding.conversationItemRecycler, bottomPadding)
|
ViewUtil.setPaddingBottom(binding.conversationItemRecycler, bottomPadding)
|
||||||
binding.conversationItemRecycler.scrollBy(0, -(bottomPadding - additionalScrollOffset))
|
binding.conversationItemRecycler.scrollBy(0, -(bottomPadding - additionalScrollOffset))
|
||||||
animationsAllowed = true
|
animationsAllowed = true
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user