Fix crash in `MessageViewContainerFragment.onPendingIntentResult()`
`onPendingIntentResult()` is called before the fragment is in the RESUMED state. This lead to an exception in the `messageViewFragment` property getter when it was checking the value of `isResumed`.
@@ -44,6 +44,10 @@ class MessageViewContainerFragment : Fragment() {
private val messageViewFragment: MessageViewFragment
get() {
check(isResumed)
+ return findMessageViewFragment()
+ }
+
+ private fun findMessageViewFragment(): MessageViewFragment {
val itemId = adapter.getItemId(messageReference)
// ViewPager2/FragmentStateAdapter don't provide an easy way to get hold of the Fragment for the active
@@ -221,7 +225,7 @@ class MessageViewContainerFragment : Fragment() {
}
fun onPendingIntentResult(requestCode: Int, resultCode: Int, data: Intent?) {
- messageViewFragment.onPendingIntentResult(requestCode, resultCode, data)
+ findMessageViewFragment().onPendingIntentResult(requestCode, resultCode, data)
}
private class MessageViewContainerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
