Work around a framework bug setting LayoutInflater.Factory2

Prior to commit 630c077463fecaa8eb1015865770f2c05c514ade in
frameworks/base there was a platform bug starting at API 11 (fixed in
API 21) that would cause a Factory2 not to be set properly on a
LayoutInflater obtained via the LayoutInflater#cloneInContext method.

The intended behavior was to merge the old Factory/Factory2 with the
new one set on the cloned LayoutInflater. Precedence is given to the
new Factory/Factory2, but if the new factory returns null, the old one
is used. The bug would cause the merge to be correct for Factory, but
not Factory2.

Now that AppCompat uses Factory2, this matters. Without this
workaround, nested fragment inflation for android-support-v4 fragments
is broken and nested fragments are inflated into the
FragmentActivity's FragmentManager instead of the parent Fragment's
child FragmentManager.

Bug 20343535

Change-Id: Ib9cd690725b365ad40d4a6cf12c1e6dc6c0089fd
4 files changed