Prevent crash that happened once
This commit is contained in:
parent
44a61a2be2
commit
2ed6fa3246
2 changed files with 13 additions and 5 deletions
|
@ -42,6 +42,10 @@ abstract class GenericFragment<T : ViewDataBinding> : Fragment() {
|
|||
protected val binding get() = _binding!!
|
||||
protected var useMaterialSharedAxisXForwardAnimation = true
|
||||
|
||||
protected fun isBindingAvailable(): Boolean {
|
||||
return _binding != null
|
||||
}
|
||||
|
||||
protected val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
lifecycleScope.launch {
|
||||
|
|
|
@ -212,11 +212,15 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
.addOnGlobalLayoutListener(
|
||||
object : OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
binding.chatMessagesList
|
||||
.viewTreeObserver
|
||||
.removeOnGlobalLayoutListener(this)
|
||||
Log.i("[Chat Room] Messages have been displayed, scrolling to first unread message if any")
|
||||
scrollToFirstUnreadMessageOrBottom(false)
|
||||
if (isBindingAvailable()) {
|
||||
binding.chatMessagesList
|
||||
.viewTreeObserver
|
||||
.removeOnGlobalLayoutListener(this)
|
||||
Log.i("[Chat Room] Messages have been displayed, scrolling to first unread message if any")
|
||||
scrollToFirstUnreadMessageOrBottom(false)
|
||||
} else {
|
||||
Log.e("[Chat Room] Binding not available in onGlobalLayout callback!")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue