Helper class for inflating layouts asynchronously. To use, construct
an instance of
AsyncLayoutInflater on the UI thread and call
inflate(int, ViewGroup, OnInflateFinishedListener). The
AsyncLayoutInflater.OnInflateFinishedListener will be invoked on the UI thread
when the inflate request has completed.
This is intended for parts of the UI that are created lazily or in
response to user interactions. This allows the UI thread to continue
to be responsive & animate while the relatively heavy inflate
is being performed.
For a layout to be inflated asynchronously it needs to have a parent
ViewGroup.generateLayoutParams(AttributeSet) is thread-safe
and all the Views being constructed as part of inflation must not create
Handlers or otherwise call
Looper.myLooper(). If the
layout that is trying to be inflated cannot be constructed
asynchronously for whatever reason,
automatically fall back to inflating on the UI thread.
NOTE that the inflated View hierarchy is NOT added to the parent. It is
equivalent to calling
LayoutInflater.inflate(int, ViewGroup, boolean)
with attachToRoot set to false. Callers will likely want to call
ViewGroup.addView(View) in the
callback at a minimum.
This inflater does not support setting a
LayoutInflater.Factory2. Similarly it does not support inflating
layouts that contain fragments.