If you have Fragments that are always tied to a sp...
# android
k
If you have Fragments that are always tied to a specific Activity, I find it useful to just throw the cast into an interface or something:
Copy code
interface CoupledFragment<A : Activity> {
    fun activity(): A = getActivity() as? A ?: throw IllegalStateException("Fragment  ${javaClass.simpleName} was not expected to be part of ${getActivity().javaClass.simpleName}")
}
(I think that compiles, did not test it...)