Fix lifecycle crashes with keyboard fragment and media sending.

This commit is contained in:
Cody Henthorne
2023-07-27 15:36:38 -04:00
parent 0a4147aa0e
commit f740b69ffe
2 changed files with 7 additions and 6 deletions

View File

@@ -514,7 +514,6 @@ class ConversationFragment :
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
registerForResults()
disposables.bindTo(viewLifecycleOwner)
FullscreenHelper(requireActivity()).showSystemUI()
@@ -523,6 +522,8 @@ class ConversationFragment :
inlineQueryViewModel = createActivityViewModel { InlineQueryViewModelV2(recipientRepository = conversationRecipientRepository) }
attachmentManager = AttachmentManager(requireContext(), requireView(), AttachmentManagerListener())
initializeConversationThreadUi()
val conversationToolbarOnScrollHelper = ConversationToolbarOnScrollHelper(
@@ -552,6 +553,8 @@ class ConversationFragment :
ToolbarDependentMarginListener(binding.toolbar)
initializeMediaKeyboard()
registerForResults()
}
override fun onViewStateRestored(savedInstanceState: Bundle?) {
@@ -799,8 +802,6 @@ class ConversationFragment :
menuProvider.afterFirstRenderMode = true
attachmentManager = AttachmentManager(requireContext(), requireView(), AttachmentManagerListener())
viewLifecycleOwner.lifecycle.addObserver(LastScrolledPositionUpdater(adapter, layoutManager, viewModel))
disposables += viewModel.recipient

View File

@@ -17,7 +17,7 @@ inline fun <reified T> Fragment.findListener(): T? {
parent = parent.parentFragment
}
return requireActivity() as? T
return activity as? T
}
/**
@@ -40,9 +40,9 @@ inline fun <reified T> Fragment.requireListener(): T {
parent = parent.parentFragment
}
return requireActivity() as T
return activity as T
} catch (e: ClassCastException) {
hierarchy.add(requireActivity()::class.java.name)
hierarchy.add(activity?.let { it::class.java.name } ?: "<null activity>")
throw ListenerNotFoundException(hierarchy, e)
}
}