add generic support for fragment types.
Merge pull request #3793 from hieupham007/fragments-30X

add generic support for fragment types.