com.facebook.litho.widget.ComponentRenderInfo Java Examples
The following examples show how to use
com.facebook.litho.widget.ComponentRenderInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LithoStartupLoggerTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void firstmount_noDataAttribution() { final RecyclerView recyclerView = new RecyclerView(mComponentContext.getAndroidContext()); final List<RenderInfo> components = new ArrayList<>(); for (int i = 0; i < 3; i++) { components.add( ComponentRenderInfo.create() .component( SimpleMountSpecTester.create(mComponentContext) .widthPx(100) .heightPx(100) .build()) .build()); } mRecyclerBinder.mount(recyclerView); mRecyclerBinder.insertRangeAt(0, components); mRecyclerBinder.notifyChangeSetComplete(true, NO_OP_CHANGE_SET_COMPLETE_CALLBACK); createBindAndMountLithoView(recyclerView, 0); assertThat(mTestLithoStartupLogger.tracePointCount()).isEqualTo(0); }
Example #2
Source File: BatchedTargetTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void testDuplicateSequentialUpdatesUseLastComponentInfo() throws Exception { Change[] ops = new Change[] { Change.update(99, ComponentRenderInfo.createEmpty()), Change.update(100, ComponentRenderInfo.createEmpty()), Change.update(101, ComponentRenderInfo.createEmpty()), Change.update(99, ComponentRenderInfo.createEmpty()), }; executeOperations(ops); verify(mMockTarget).updateRange(eq(99), eq(3), mListCaptor.capture()); assertThat(ops[3].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(0)); assertThat(ops[1].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(1)); assertThat(ops[2].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(2)); }
Example #3
Source File: BatchedTargetTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void testConsolidateDifferentTypes() throws Exception { Change[] ops = new Change[] { Change.remove(2), Change.remove(1), Change.update(99, ComponentRenderInfo.createEmpty()), Change.update(100, ComponentRenderInfo.createEmpty()), Change.insert(0, ComponentRenderInfo.createEmpty()), Change.insert(1, ComponentRenderInfo.createEmpty()), Change.update(101, ComponentRenderInfo.createEmpty()), Change.update(99, ComponentRenderInfo.createEmpty()), Change.move(14, 55), }; executeOperations(ops); verify(mMockTarget).deleteRange(1, 2); verify(mMockTarget).updateRange(eq(99), eq(2), anyList()); verify(mMockTarget).insertRange(eq(0), eq(2), anyList()); verify(mMockTarget).update(101, ops[6].getRenderInfo()); verify(mMockTarget).update(99, ops[7].getRenderInfo()); verify(mMockTarget).move(14, 55); }
Example #4
Source File: BatchedTargetTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void testConsolidateSequentialUpdates() throws Exception { Change[] ops = new Change[] { Change.update(2, ComponentRenderInfo.createEmpty()), Change.update(1, ComponentRenderInfo.createEmpty()), Change.update(20, ComponentRenderInfo.createEmpty()), Change.update(21, ComponentRenderInfo.createEmpty()), }; executeOperations(ops); verify(mMockTarget).updateRange(eq(1), eq(2), mListCaptor.capture()); assertThat(ops[1].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(0)); assertThat(ops[0].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(1)); verify(mMockTarget).updateRange(eq(20), eq(2), mListCaptor.capture()); assertThat(ops[2].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(0)); assertThat(ops[3].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(1)); }
Example #5
Source File: BatchedTargetTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void testDuplicateIndexInserts() throws Exception { Change[] ops = new Change[] { Change.insert(0, ComponentRenderInfo.createEmpty()), Change.insert(1, ComponentRenderInfo.createEmpty()), Change.insert(1, ComponentRenderInfo.createEmpty()), Change.insert(20, ComponentRenderInfo.createEmpty()), }; executeOperations(ops); verify(mMockTarget).insertRange(eq(0), eq(2), mListCaptor.capture()); assertThat(ops[0].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(0)); assertThat(ops[1].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(1)); verify(mMockTarget).insert(1, ops[2].getRenderInfo()); verify(mMockTarget).insert(20, ops[3].getRenderInfo()); }
Example #6
Source File: SectionTreeTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void testUniqueGlobalKeys() { final Section leaf1 = TestSectionCreator.createChangeSetComponent( "leaf1", Change.insert(0, ComponentRenderInfo.createEmpty()), Change.insert(1, ComponentRenderInfo.createEmpty()), Change.insert(2, ComponentRenderInfo.createEmpty())); final Section leaf2 = TestSectionCreator.createChangeSetComponent( "leaf1", Change.insert(0, ComponentRenderInfo.createEmpty()), Change.insert(1, ComponentRenderInfo.createEmpty())); final Section root = TestSectionCreator.createSectionComponent("node1", leaf1, leaf2); final TestTarget changeSetHandler = new TestTarget(); SectionTree tree = SectionTree.create(mSectionContext, changeSetHandler).build(); tree.setRoot(root); assertThat(leaf1.getGlobalKey()).isEqualTo("node1leaf1"); assertThat(leaf2.getGlobalKey()).isEqualTo("node1leaf10"); }
Example #7
Source File: BatchedTargetTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void testOnlyConsolidateInsertsIfSequentialIndexes() throws Exception { Change[] ops = new Change[] { Change.insert(0, ComponentRenderInfo.createEmpty()), Change.insert(1, ComponentRenderInfo.createEmpty()), Change.insert(20, ComponentRenderInfo.createEmpty()), }; executeOperations(ops); verify(mMockTarget).insertRange(eq(0), eq(2), mListCaptor.capture()); assertThat(ops[0].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(0)); assertThat(ops[1].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(1)); verify(mMockTarget).insert(20, ops[2].getRenderInfo()); }
Example #8
Source File: BatchedTargetTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void testConsolidateSequentialInserts() throws Exception { Change[] ops = new Change[] { Change.insert(0, ComponentRenderInfo.createEmpty()), Change.insert(1, ComponentRenderInfo.createEmpty()), Change.insert(2, ComponentRenderInfo.createEmpty()), }; executeOperations(ops); verify(mMockTarget).insertRange(eq(0), eq(3), mListCaptor.capture()); assertThat(ops[0].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(0)); assertThat(ops[1].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(1)); assertThat(ops[2].getRenderInfo()).isEqualTo(mListCaptor.getValue().get(2)); }
Example #9
Source File: BatchedTargetTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void testLoggerDelete() throws Exception { assumeThat( "Logging is only available in debug mode.", ComponentsConfiguration.IS_INTERNAL_BUILD, is(true)); Change[] ops = new Change[] { Change.insert(0, ComponentRenderInfo.createEmpty()), Change.remove(0), }; executeOperations(ops); verify(mMockSectionsDebugLogger) .logInsert("", 0, ops[0].getRenderInfo(), Thread.currentThread().getName()); verify(mMockSectionsDebugLogger).logDelete("", 0, Thread.currentThread().getName()); }
Example #10
Source File: SingleComponentSectionSpec.java From litho with Apache License 2.0 | 6 votes |
private static ComponentRenderInfo.Builder addCustomAttributes( ComponentRenderInfo.Builder builder, @Nullable Map<String, Object> attributes, SectionContext c, Diff<Component> component) { if (ComponentsConfiguration.isRenderInfoDebuggingEnabled()) { builder.debugInfo(SONAR_SECTIONS_DEBUG_INFO_TAG, c.getSectionScope()); builder.debugInfo(SONAR_SINGLE_COMPONENT_SECTION_DATA_PREV, component.getPrevious()); builder.debugInfo(SONAR_SINGLE_COMPONENT_SECTION_DATA_NEXT, component.getNext()); } if (attributes == null) { return builder; } for (Map.Entry<String, Object> entry : attributes.entrySet()) { builder.customAttribute(entry.getKey(), entry.getValue()); } return builder; }
Example #11
Source File: BorderEffectsComponentSpec.java From litho with Apache License 2.0 | 6 votes |
@OnEvent(RenderEvent.class) static RenderInfo onRender(ComponentContext c, @FromEvent Class<? extends Component> model) { try { Method createMethod = model.getMethod("create", ComponentContext.class); Component.Builder componentBuilder = (Component.Builder) createMethod.invoke(null, c); return ComponentRenderInfo.create().component(componentBuilder.build()).build(); } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { return ComponentRenderInfo.create() .component(Text.create(c).textSizeDip(32).text(ex.getLocalizedMessage()).build()) .build(); } }
Example #12
Source File: Message.java From litho with Apache License 2.0 | 6 votes |
public RenderInfo createComponent(ComponentContext c) { final Component component = mIsMe ? ExpandableElementMe.create(c) .messageText(mMessage) .timestamp(mTimestamp) .seen(mSeen) .forceAnimateOnAppear(mForceAnimateOnAppear) .build() : ExpandableElementOther.create(c) .messageText(mMessage) .timestamp(mTimestamp) .seen(mSeen) .build(); return ComponentRenderInfo.create().component(component).build(); }
Example #13
Source File: ComposedAnimationsComponentSpec.java From litho with Apache License 2.0 | 6 votes |
@OnEvent(RenderEvent.class) static RenderInfo onRender(ComponentContext c, @FromEvent int index) { final int numDemos = 5; Component component; // Keep alternating between demos switch (index % numDemos) { case 0: component = StoryFooterComponent.create(c).key("footer").build(); break; case 1: component = UpDownBlocksComponent.create(c).build(); break; case 2: component = LeftRightBlocksComponent.create(c).build(); break; case 3: component = OneByOneLeftRightBlocksComponent.create(c).build(); break; case 4: component = LeftRightBlocksSequenceComponent.create(c).build(); break; default: throw new RuntimeException("Bad index: " + index); } return ComponentRenderInfo.create().component(component).build(); }
Example #14
Source File: LithoStartupLoggerTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void firstlayout_withDataAttribution() { mTestLithoStartupLogger.setDataAttribution("myquery"); final List<RenderInfo> components = new ArrayList<>(); for (int i = 0; i < 3; i++) { components.add( ComponentRenderInfo.create() .component( SimpleMountSpecTester.create(mComponentContext) .widthPx(100) .heightPx(100) .build()) .build()); } mRecyclerBinder.insertRangeAt(0, components); mRecyclerBinder.notifyChangeSetComplete(true, NO_OP_CHANGE_SET_COMPLETE_CALLBACK); mRecyclerBinder.measure( new Size(), makeSizeSpec(1000, EXACTLY), makeSizeSpec(1000, EXACTLY), null); assertThat(mTestLithoStartupLogger.tracePointCount()).isEqualTo(2); assertThat(mTestLithoStartupLogger.getTracedPointAt(0)) .isEqualTo("litho_ui_myquery_firstlayout_start"); assertThat(mTestLithoStartupLogger.getTracedPointAt(1)) .isEqualTo("litho_ui_myquery_firstlayout_end"); }
Example #15
Source File: ChangeTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void testCreateChangeNullInList() { final List<RenderInfo> renderInfos = new ArrayList<>(); renderInfos.add(ComponentRenderInfo.createEmpty()); renderInfos.add(null); final Change change = Change.insertRange(0, 5, renderInfos); assertThat(change.getRenderInfo()).isNotNull(); final List<RenderInfo> changeRenderInfos = change.getRenderInfos(); assertThat(changeRenderInfos).isNotNull(); assertThat(changeRenderInfos.get(0)).isNotNull(); assertThat(changeRenderInfos.get(1)).isNotNull(); }
Example #16
Source File: LithoStartupLoggerTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void firstlayout_noDataAttribution() { final List<RenderInfo> components = new ArrayList<>(); for (int i = 0; i < 3; i++) { components.add( ComponentRenderInfo.create() .component( SimpleMountSpecTester.create(mComponentContext) .widthPx(100) .heightPx(100) .build()) .build()); } mRecyclerBinder.insertRangeAt(0, components); mRecyclerBinder.measure( new Size(), makeSizeSpec(1000, EXACTLY), makeSizeSpec(1000, EXACTLY), null); assertThat(mTestLithoStartupLogger.tracePointCount()).isEqualTo(2); assertThat(mTestLithoStartupLogger.getTracedPointAt(0)).isEqualTo("litho_ui_firstlayout_start"); assertThat(mTestLithoStartupLogger.getTracedPointAt(1)).isEqualTo("litho_ui_firstlayout_end"); }
Example #17
Source File: ChangeTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void testUpdateRange() { final List<RenderInfo> renderInfos = new ArrayList<>(); final List<Object> oldData = new ArrayList<>(); final List<Object> newData = new ArrayList<>(); for (int i = 0; i < 5; i++) { renderInfos.add(ComponentRenderInfo.createEmpty()); oldData.add(new Object()); newData.add(new Object()); } final Change change = Change.updateRange(0, 5, renderInfos, oldData, newData); assertThat(change.getRenderInfo()).isNotNull(); assertThat(change.getRenderInfos()).isNotEmpty(); assertThat(change.getPrevData()).isEqualTo(oldData); assertThat(change.getNextData()).isEqualTo(newData); }
Example #18
Source File: ChangeSetTest.java From litho with Apache License 2.0 | 6 votes |
@Test public void testAddChange() { final ChangeSet changeSet = ChangeSet.acquireChangeSet(null, false); changeSet.addChange(Change.insert(0, ComponentRenderInfo.createEmpty())); assertThat(changeSet.getCount()).isEqualTo(1); changeSet.addChange(Change.remove(0)); assertThat(changeSet.getCount()).isEqualTo(0); changeSet.addChange(Change.insert(0, ComponentRenderInfo.createEmpty())); assertThat(changeSet.getCount()).isEqualTo(1); changeSet.addChange(Change.update(0, ComponentRenderInfo.createEmpty())); assertThat(changeSet.getCount()).isEqualTo(1); changeSet.addChange(Change.insert(0, ComponentRenderInfo.createEmpty())); assertThat(changeSet.getCount()).isEqualTo(2); changeSet.addChange(Change.move(0, 1)); assertThat(changeSet.getCount()).isEqualTo(2); }
Example #19
Source File: HorizontalScrollWithSnapComponentSpec.java From litho with Apache License 2.0 | 6 votes |
@OnEvent(RenderEvent.class) static RenderInfo onRender(ComponentContext c, @FromEvent Object model, @FromEvent int index) { return ComponentRenderInfo.create() .component( Row.create(c) .justifyContent(YogaJustify.CENTER) .widthDip(120) .heightDip(120) .backgroundColor((int) model) .child( Text.create(c) .textSizeSp(20) .textColor(Color.LTGRAY) .text(Integer.toString(index)) .verticalGravity(VerticalGravity.CENTER))) .build(); }
Example #20
Source File: ListSectionSpec.java From litho with Apache License 2.0 | 6 votes |
@OnEvent(RenderEvent.class) static RenderInfo onRender(final SectionContext c, @FromEvent Integer model) { if (model.intValue() == 1) { return ViewRenderInfo.create() .viewBinder( new SimpleViewBinder<TextView>() { @Override public void bind(TextView textView) { textView.setText("I'm a view in a Litho world"); } }) .viewCreator(VIEW_CREATOR) .build(); } return ComponentRenderInfo.create() .component( ListItem.create(c) .color(model % 2 == 0 ? Color.WHITE : Color.LTGRAY) .title(model + ". Hello, world!") .subtitle("Litho tutorial") .build()) .build(); }
Example #21
Source File: Demos.java From litho-glide with MIT License | 5 votes |
public static void addAllToBinder(RecyclerBinder recyclerBinder, ComponentContext c) { for (String name : demoModels.keySet()) { ComponentRenderInfo.Builder componentInfoBuilder = ComponentRenderInfo.create(); componentInfoBuilder.component(DemoListItemComponent.create(c).name(name).build()); recyclerBinder.insertItemAt(recyclerBinder.getItemCount(), componentInfoBuilder.build()); } }
Example #22
Source File: DataModel.java From litho-picasso with MIT License | 5 votes |
public static void populateBinderWithSampleDataForPicasso(RecyclerBinder recyclerBinder, ComponentContext c) { final Datum[] dataModels = SampleData(); for (Datum datum : dataModels) { ComponentRenderInfo.Builder componentInfoBuilder = ComponentRenderInfo.create(); componentInfoBuilder.component(datum.createComponent(c)).isSticky(datum instanceof Decade); recyclerBinder.insertItemAt(recyclerBinder.getItemCount(), componentInfoBuilder.build()); } }
Example #23
Source File: PicassoArtist.java From litho-picasso with MIT License | 5 votes |
@Override public Component createComponent(ComponentContext c) { final RecyclerBinder imageRecyclerBinder = new RecyclerBinder.Builder().layoutInfo( new LinearLayoutInfo(c, OrientationHelper.HORIZONTAL, false)).build(c); for (String image : images) { ComponentRenderInfo.Builder imageComponentInfoBuilder = ComponentRenderInfo.create(); imageComponentInfoBuilder.component( PicassoSingleImageComponent.create(c).image(image).fit(true).build()); imageRecyclerBinder.insertItemAt(imageRecyclerBinder.getItemCount(), imageComponentInfoBuilder.build()); } return FeedItemCard.create(c).artist(this).binder(imageRecyclerBinder).build(); }
Example #24
Source File: Demos.java From litho-picasso with MIT License | 5 votes |
public static void addAllToBinder(RecyclerBinder recyclerBinder, ComponentContext c) { for (String name : demoModels.keySet()) { ComponentRenderInfo.Builder componentInfoBuilder = ComponentRenderInfo.create(); componentInfoBuilder.component( DemoListItemComponent.create(c) .name(name) .build()); recyclerBinder.insertItemAt(recyclerBinder.getItemCount(), componentInfoBuilder.build()); } }
Example #25
Source File: ChangeSetTest.java From litho with Apache License 2.0 | 5 votes |
@Test public void testMerge() { final ChangeSet changeSet = ChangeSet.acquireChangeSet(null, false); changeSet.addChange(Change.insert(0, ComponentRenderInfo.createEmpty())); changeSet.addChange(Change.insert(1, ComponentRenderInfo.createEmpty())); changeSet.addChange(Change.insert(2, ComponentRenderInfo.createEmpty())); final ChangeSet secondChangeSet = ChangeSet.acquireChangeSet(null, false); secondChangeSet.addChange(Change.insert(0, ComponentRenderInfo.createEmpty())); secondChangeSet.addChange(Change.insert(1, ComponentRenderInfo.createEmpty())); secondChangeSet.addChange(Change.insert(2, ComponentRenderInfo.createEmpty())); secondChangeSet.addChange(Change.move(0, 1)); final ChangeSet mergedChangeSet = ChangeSet.merge(changeSet, secondChangeSet); assertThat(changeSet.getCount()).isEqualTo(3); assertThat(secondChangeSet.getCount()).isEqualTo(3); for (int i = 0; i < 3; i++) { assertThat(changeSet.getChangeAt(i).getIndex()).isEqualTo(i); } for (int i = 0; i < 3; i++) { assertThat(secondChangeSet.getChangeAt(i).getIndex()).isEqualTo(i); } assertThat(mergedChangeSet.getCount()).isEqualTo(6); assertThat(mergedChangeSet.getChangeCount()).isEqualTo(7); for (int i = 0; i < 6; i++) { assertThat(mergedChangeSet.getChangeAt(i).getIndex()).isEqualTo(i); } assertThat(mergedChangeSet.getChangeAt(6).getType()).isEqualTo(MOVE); assertThat(mergedChangeSet.getChangeAt(6).getIndex()).isEqualTo(3); assertThat(mergedChangeSet.getChangeAt(6).getToIndex()).isEqualTo(4); }
Example #26
Source File: LithoStartupLoggerTest.java From litho with Apache License 2.0 | 5 votes |
@Test public void firstmount_withDataAttribution() { mTestLithoStartupLogger.setDataAttribution("myquery"); final RecyclerView recyclerView = new RecyclerView(mComponentContext.getAndroidContext()); final List<RenderInfo> components = new ArrayList<>(); for (int i = 0; i < 3; i++) { components.add( ComponentRenderInfo.create() .component( SimpleMountSpecTester.create(mComponentContext) .widthPx(100) .heightPx(100) .build()) .build()); } mRecyclerBinder.mount(recyclerView); mRecyclerBinder.insertRangeAt(0, components); mRecyclerBinder.notifyChangeSetComplete(true, NO_OP_CHANGE_SET_COMPLETE_CALLBACK); createBindAndMountLithoView(recyclerView, 0); assertThat(mTestLithoStartupLogger.tracePointCount()).isEqualTo(2); assertThat(mTestLithoStartupLogger.getTracedPointAt(0)) .isEqualTo("litho_myquery_firstmount_start"); assertThat(mTestLithoStartupLogger.getTracedPointAt(1)) .isEqualTo("litho_myquery_firstmount_end"); }
Example #27
Source File: ChangeSetStateTest.java From litho with Apache License 2.0 | 5 votes |
private static Section createChangeSetComponent(String key, int numChildren) { Change[] changes = new Change[numChildren]; for (int i = 0; i < numChildren; i++) { changes[i] = Change.insert(i, ComponentRenderInfo.createEmpty()); } return TestSectionCreator.createChangeSetComponent(key, changes); }
Example #28
Source File: ChangeSetTest.java From litho with Apache License 2.0 | 5 votes |
@Test public void testAddChangeWithData() { final ChangeSet changeSet = ChangeSet.acquireChangeSet(null, false); final Object data1 = new Object(); changeSet.addChange(Change.insert(0, ComponentRenderInfo.createEmpty(), data1)); assertThat(changeSet.getCount()).isEqualTo(1); assertThat(changeSet.getChanges().get(0).getPrevData()).isNull(); assertThat(changeSet.getChanges().get(0).getNextData()).isEqualTo(ImmutableList.of(data1)); changeSet.addChange(Change.remove(0, data1)); assertThat(changeSet.getCount()).isEqualTo(0); assertThat(changeSet.getChanges().get(1).getPrevData()).isEqualTo(ImmutableList.of(data1)); assertThat(changeSet.getChanges().get(1).getNextData()).isNull(); final Object data2 = new Object(); changeSet.addChange(Change.insert(0, ComponentRenderInfo.createEmpty(), data2)); assertThat(changeSet.getCount()).isEqualTo(1); assertThat(changeSet.getChanges().get(2).getPrevData()).isNull(); assertThat(changeSet.getChanges().get(2).getNextData()).isEqualTo(ImmutableList.of(data2)); final Object data3 = new Object(); changeSet.addChange(Change.update(0, ComponentRenderInfo.createEmpty(), data2, data3)); assertThat(changeSet.getCount()).isEqualTo(1); assertThat(changeSet.getChanges().get(3).getPrevData()).isEqualTo(ImmutableList.of(data2)); assertThat(changeSet.getChanges().get(3).getNextData()).isEqualTo(ImmutableList.of(data3)); final Object data4 = new Object(); changeSet.addChange(Change.insert(0, ComponentRenderInfo.createEmpty(), data4)); assertThat(changeSet.getCount()).isEqualTo(2); assertThat(changeSet.getChanges().get(4).getPrevData()).isNull(); assertThat(changeSet.getChanges().get(4).getNextData()).isEqualTo(ImmutableList.of(data4)); changeSet.addChange(Change.move(0, 1, data4)); assertThat(changeSet.getCount()).isEqualTo(2); assertThat(changeSet.getChanges().get(5).getPrevData()).isEqualTo(ImmutableList.of(data4)); assertThat(changeSet.getChanges().get(5).getNextData()).isEqualTo(ImmutableList.of(data4)); }
Example #29
Source File: ChangeSetTest.java From litho with Apache License 2.0 | 5 votes |
@Test public void testRelease() { final ChangeSet changeSet = ChangeSet.acquireChangeSet(null, false); changeSet.addChange(Change.insert(0, ComponentRenderInfo.createEmpty())); changeSet.addChange(Change.insert(1, ComponentRenderInfo.createEmpty())); changeSet.addChange(Change.insert(2, ComponentRenderInfo.createEmpty())); changeSet.release(); assertThat(changeSet.getCount()).isEqualTo(0); assertThat(changeSet.getChangeCount()).isEqualTo(0); }
Example #30
Source File: SimpleGallerySectionSpec.java From fresco with MIT License | 5 votes |
@OnEvent(RenderEvent.class) static RenderInfo onRender(final SectionContext c, @FromEvent Uri model) { return ComponentRenderInfo.create() .component( FrescoVitoImage2.create(c) .uri(model) .imageOptions(IMAGE_OPTIONS) .paddingDip(YogaEdge.ALL, 2)) .build(); }