mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Fix lifecycle crashes when fragment is destroy before async callbacks.
This commit is contained in:
@@ -798,6 +798,12 @@ class ConversationFragment :
|
|||||||
|
|
||||||
private fun doAfterFirstRender() {
|
private fun doAfterFirstRender() {
|
||||||
Log.d(TAG, "doAfterFirstRender")
|
Log.d(TAG, "doAfterFirstRender")
|
||||||
|
|
||||||
|
if (!isAdded || view == null) {
|
||||||
|
Log.w(TAG, "Bailing, fragment no longer added")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
activity?.supportStartPostponedEnterTransition()
|
activity?.supportStartPostponedEnterTransition()
|
||||||
|
|
||||||
backPressedCallback = BackPressedDelegate()
|
backPressedCallback = BackPressedDelegate()
|
||||||
@@ -2149,6 +2155,10 @@ class ConversationFragment :
|
|||||||
private inner class StartPositionScroller(private val meta: ConversationData) : ViewTreeObserver.OnGlobalLayoutListener {
|
private inner class StartPositionScroller(private val meta: ConversationData) : ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
|
|
||||||
override fun onGlobalLayout() {
|
override fun onGlobalLayout() {
|
||||||
|
if (!isAdded || view == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val rect = Rect()
|
val rect = Rect()
|
||||||
binding.toolbar.getGlobalVisibleRect(rect)
|
binding.toolbar.getGlobalVisibleRect(rect)
|
||||||
val toolbarOffset = rect.bottom
|
val toolbarOffset = rect.bottom
|
||||||
@@ -3907,6 +3917,10 @@ class ConversationFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onGlobalLayout() {
|
override fun onGlobalLayout() {
|
||||||
|
if (!isAdded || view == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val rect = Rect()
|
val rect = Rect()
|
||||||
toolbar.getGlobalVisibleRect(rect)
|
toolbar.getGlobalVisibleRect(rect)
|
||||||
threadHeaderMarginDecoration.toolbarMargin = rect.bottom + 16.dp
|
threadHeaderMarginDecoration.toolbarMargin = rect.bottom + 16.dp
|
||||||
|
|||||||
Reference in New Issue
Block a user