@Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { final ComponentTree componentTree = mComponentTree.get(); if (componentTree != null) { componentTree.incrementalMountComponent(); } }
public void performIncrementalMount() { if (mComponentTree == null || mComponentTree.getMainThreadLayoutState() == null) { return; } if (mComponentTree.isIncrementalMountEnabled()) { mComponentTree.incrementalMountComponent(); } else { throw new IllegalStateException("To perform incremental mounting, you need first to enable" + " it when creating the ComponentTree."); } }
private boolean mountComponentIfNeeded() { if (mLithoView.isMountStateDirty() || mLithoView.mountStateNeedsRemount()) { if (mIncrementalMountEnabled) { incrementalMountComponent(); } else { mountComponent(null, true); } return true; } return false; }
@Test public void testGetLocalVisibleBounds() { doAnswer( new Answer<Boolean>() { @Override public Boolean answer(InvocationOnMock invocation) throws Throwable { Rect rect = (Rect) invocation.getArguments()[0]; rect.set(new Rect(10, 5, 20, 15)); return true; } }) .when(mLithoView) .getLocalVisibleRect(any(Rect.class)); mComponentTree.incrementalMountComponent(); assertThat(mMountedRect).isEqualTo(new Rect(10, 5, 20, 15)); }
@Test public void testIncrementalMountTriggeredAfterUnmountAllWithSameDimensions() { mComponentTree = createComponentTree(true, true, 100, 100); final int WIDTH = 50; final int HEIGHT = 50; mLithoView.setMeasured(WIDTH, HEIGHT); mLithoView.setComponentTree(mComponentTree); mLithoView.onAttachedToWindow(); mLithoView.layout(0, 0, mLithoView.getMeasuredWidth(), mLithoView.getMeasuredHeight()); verify(mComponentTree).incrementalMountComponent(); mLithoView.unmountAllItems(); mLithoView.performLayout(false, 0, 0, WIDTH, HEIGHT); verify(mComponentTree, times(2)).incrementalMountComponent(); }