Class ViewPump.Builder
-
- All Implemented Interfaces:
public final class ViewPump.Builder
-
-
Method Summary
Modifier and Type Method Description final ViewPump.BuilderaddInterceptor(Interceptor interceptor)final ViewPump.BuildersetPrivateFactoryInjectionEnabled(Boolean enabled)Turn of the use of Reflection to inject the private factory. final ViewPump.BuildersetCustomViewInflationEnabled(Boolean enabled)Due to the poor inflation order where custom views are created and never returned inside an onCreateView(...)method.final ViewPump.BuildersetReflectiveFallbackViewCreator(FallbackViewCreator reflectiveFallbackViewCreator)final ViewPump.BuildersetStoreLayoutResId(Boolean enabled)The LayoutInflater can store the layout resourceId used to inflate a view into the inflated view's tag where it can be later retrieved by an interceptor. final ViewPumpbuild()-
-
Method Detail
-
addInterceptor
final ViewPump.Builder addInterceptor(Interceptor interceptor)
-
setPrivateFactoryInjectionEnabled
final ViewPump.Builder setPrivateFactoryInjectionEnabled(Boolean enabled)
Turn of the use of Reflection to inject the private factory. This has operational consequences! Please read and understand before disabling.
If you disable this you will need to override your android.app.Activity.onCreateView as this is set as the android.view.LayoutInflater private factory.
** Use the following code in the Activity if you disable FactoryInjection:**
@Override public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { return ViewPumpContextWrapper.onActivityCreateView(this, parent, super.onCreateView(parent, name, context, attrs), name, context, attrs); }@Override override fun onCreateView(parent: View, name: String, context: Context, attrs: AttributeSet): View { return ViewPumpContextWrapper.onActivityCreateView(this, parent, super.onCreateView(parent, name, context, attrs), name, context, attrs) }- Parameters:
enabled- True if private factory inject is allowed; otherwise, false.
-
setCustomViewInflationEnabled
final ViewPump.Builder setCustomViewInflationEnabled(Boolean enabled)
Due to the poor inflation order where custom views are created and never returned inside an
onCreateView(...)method. We have to create CustomView's at the latest point in the overrideable injection flow.On HoneyComb+ this is inside the android.app.Activity.onCreateView
We wrap base implementations, so if you LayoutInflater/Factory/Activity creates the custom view before we get to this point, your view is used. (Such is the case with the TintEditText etc)
The problem is, the native methods pass there parents context to the constructor in a really specific place. We have to mimic this in ViewPumpLayoutInflater.createCustomViewInternal To mimic this we have to use reflection as the Class constructor args are hidden to us.
We have discussed other means of doing this but this is the only semi-clean way of doing it. (Without having to do proxy classes etc).
Calling this will of course speed up inflation by turning off reflection, but not by much, But if you want ViewPump to inject the correct typeface then you will need to make sure your CustomView's are created before reaching the LayoutInflater onViewCreated.
- Parameters:
enabled- True if custom view inflated is allowed; otherwise, false.
-
setReflectiveFallbackViewCreator
final ViewPump.Builder setReflectiveFallbackViewCreator(FallbackViewCreator reflectiveFallbackViewCreator)
-
setStoreLayoutResId
final ViewPump.Builder setStoreLayoutResId(Boolean enabled)
The LayoutInflater can store the layout resourceId used to inflate a view into the inflated view's tag where it can be later retrieved by an interceptor.
- Parameters:
enabled- True if the view should store the resId; otherwise, false.
-
-
-
-