/** * Mount a component into a component view. * * @param context A components context * @param lithoView The view to mount the component into * @param component The component to mount * @param incrementalMountEnabled States whether incremental mount is enabled * @param width The width of the resulting view * @param height The height of the resulting view * @return A LithoView with the component mounted in it. */ public static LithoView mountComponent( ComponentContext context, LithoView lithoView, Component component, boolean incrementalMountEnabled, int width, int height) { return mountComponent( lithoView, ComponentTree.create(context, component) .incrementalMount(incrementalMountEnabled) .layoutDiffing(false) .build(), makeMeasureSpec(width, EXACTLY), makeMeasureSpec(height, EXACTLY)); }
@Override public void bind(@NonNull LithoView view) { Component<T> component = getComponent(view.getComponentContext()); if (view.getComponentTree() == null) { view.setComponentTree(ComponentTree.create(view.getComponentContext(), component) .asyncStateUpdates(false) // does this need to be off? .layoutThreadLooper(Looper.getMainLooper()) .incrementalMount( false) // this needs to be off for recyclerview to work. Should we manually // incrementally mount views in a scroll listener? .layoutDiffing(false) // should we use this? .build()); } view.setComponent(component); }
final ComponentTree componentTree = ComponentTree.create(mContext, oldComponent) .incrementalMount(false) .layoutDiffing(true) .build();
.incrementalMount(incrementalMountEnabled) .layoutDiffing(false) .build();
final ComponentTree componentTree = ComponentTree.create(mContext, oldComponent) .incrementalMount(false) .layoutDiffing(true) .build();
final ComponentTree componentTree = ComponentTree.create(mContext, oldComponent) .incrementalMount(false) .layoutDiffing(true) .build();
@OnCreateInitialState static void onCreateInitialState( ComponentContext context, StateValue<ScrollPosition> scrollPosition, StateValue<ComponentTree> childComponentTree, @Prop(optional = true) Integer initialScrollOffsetPixels, @Prop(optional = true) boolean incrementalMountEnabled, @Prop Component childComponent) { ScrollPosition initialScrollPosition = new ScrollPosition(); initialScrollPosition.y = initialScrollOffsetPixels == null ? 0 : initialScrollOffsetPixels; scrollPosition.set(initialScrollPosition); childComponentTree.set( ComponentTree.create( new ComponentContext( context.getAndroidContext(), context.getLogTag(), context.getLogger(), context.getTreePropsCopy()), childComponent) .incrementalMount(incrementalMountEnabled) .build()); }
@Override public Builder incrementalMount(boolean isEnabled) { return (Builder) super.incrementalMount(isEnabled); }
private ComponentTree createComponentTree(boolean useSpy, boolean incMountEnabled, int width, int height) { ComponentTree componentTree = ComponentTree.create(mContext, mComponent) .incrementalMount(incMountEnabled) .layoutDiffing(false) .build(); componentTree.setSizeSpec( SizeSpec.makeSizeSpec(width, EXACTLY), SizeSpec.makeSizeSpec(height, EXACTLY)); return useSpy ? spy(componentTree) : componentTree; }
void mount(Component component, int width, int height) { if (mLithoView.getComponentTree() == null) { mLithoView.setComponentTree( ComponentTree.create(mLithoView.getComponentContext(), component) .incrementalMount(false) .build()); } else { mLithoView.setComponent(component); } mComponentWidth = width; mComponentHeight = height; }