@ SuppressWarnings ( "unchecked" ) public < T > T findCallback ( Fragment fragment , Class < T > callbackType ) { Fragment back = getBackFragment ( fragment ) ; if ( back != null && callbackType . isAssignableFrom ( back . getClass ( ) ) ) return ( T ) back ; if ( callbackType . isAssignableFrom ( activity . getClass ( ) ) ) return ( T ) activity ; return null ; }
Returns a back fragment if the fragment is of given class . If such fragment does not exist and activity implements the given class then the activity will be returned .