If you compare direct and indirect subclasses of ViewGroup and ViewParent, they look the same (taking into account the ViewGroup itself).
However, it is possible that in some user library you can get from getParent() a ViewParent , which is not a ViewGroup . Is this a real case?
So, if you cannot be sure of the parent type, you better check it out.
- in a regular application, you usually understand which parent or maybe - and therefore you can skip the check
source share