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

@@ -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)
}
}