Java Code Examples for com.facebook.litho.StateValue#set()
The following examples show how to use
com.facebook.litho.StateValue#set() .
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: ExpandableElementRootComponentSpec.java From litho with Apache License 2.0 | 6 votes |
@OnUpdateState static void onUpdateList( StateValue<List<Message>> messages, StateValue<Integer> counter, @Param boolean adding, @Param int initialMessagesSize) { final ArrayList<Message> updatedMessageList = new ArrayList<>(messages.get()); int counterValue = counter.get(); if (adding) { updatedMessageList.add( 1, new Message(true, "Just Added #" + counterValue, true, "Recently", true)); counter.set(counterValue + 1); } else if (initialMessagesSize < updatedMessageList.size()) { updatedMessageList.remove(1); } messages.set(updatedMessageList); }
Example 2
Source File: FastScrollHandleComponentSpec.java From litho with Apache License 2.0 | 6 votes |
@OnCreateInitialState static void onCreateInitialState( ComponentContext c, StateValue<RecyclerCollectionEventsController> recyclerEventsController, StateValue<DynamicValue<Float>> handleTranslation, StateValue<ScrollController> scrollController) { final RecyclerCollectionEventsController recyclerEventsControllerValue = new RecyclerCollectionEventsController(); final DynamicValue<Float> handleTranslationValue = new DynamicValue<>(0f); final ScrollController scrollControllerValue = new ScrollController(recyclerEventsControllerValue, handleTranslationValue); recyclerEventsController.set(recyclerEventsControllerValue); handleTranslation.set(handleTranslationValue); scrollController.set(scrollControllerValue); }
Example 3
Source File: ExpandableElementOtherSpec.java From litho with Apache License 2.0 | 6 votes |
@OnUpdateStateWithTransition static Transition updateExpandedState(StateValue<Boolean> expanded, @Param boolean expand) { expanded.set(expand); return Transition.parallel( Transition.allLayout(), Transition.create( Transition.TransitionKeyType.GLOBAL, ExpandableElementUtil.TRANSITION_TOP_DETAIL) .animate(AnimatedProperties.HEIGHT) .appearFrom(0) .disappearTo(0), Transition.create( Transition.TransitionKeyType.GLOBAL, ExpandableElementUtil.TRANSITION_BOTTOM_DETAIL) .animate(AnimatedProperties.HEIGHT) .appearFrom(0) .disappearTo(0)); }
Example 4
Source File: FullDiffSection.java From litho with Apache License 2.0 | 5 votes |
@Override public void updateState(StateContainer _stateContainer) { FullDiffSectionStateContainer<T> stateContainer = (FullDiffSectionStateContainer<T>) _stateContainer; StateValue<Object> state1 = new StateValue<Object>(); state1.set(stateContainer.state1); FullDiffSectionSpec.updateState(state1, mParam); stateContainer.state1 = state1.get(); }
Example 5
Source File: AnimationStateExampleComponentSpec.java From litho with Apache License 2.0 | 5 votes |
@OnUpdateState static void updatePosition(StateValue<String> actualPosition, @Param boolean alignStart) { if (alignStart) { actualPosition.set(STATE_START); } else { actualPosition.set(STATE_END); } }
Example 6
Source File: LifecycleDelegateComponentSpec.java From litho with Apache License 2.0 | 5 votes |
@OnCreateInitialState static void onCreateInitialState( ComponentContext c, StateValue<Random> random, StateValue<Integer> colorIndex, @Prop DelegateListener delegateListener, @Prop int id) { final Random rand = new Random(); random.set(rand); colorIndex.set(rand.nextInt(COLORS.length)); onDelegateMethodCalled(delegateListener, ON_CREATE_INITIAL_STATE, id); }
Example 7
Source File: AnimatedBadgeSpec.java From litho with Apache License 2.0 | 4 votes |
@OnUpdateState static void updateState(StateValue<Integer> state) { state.set((state.get() + 1) % 4); }
Example 8
Source File: MultipleComponentMovesTransitionSpec.java From litho with Apache License 2.0 | 4 votes |
@OnCreateInitialState static void onCreateInitialState(ComponentContext c, StateValue<Deck> deck) { deck.set(Deck.ORDERED); }
Example 9
Source File: VerySimpleGroupSectionSpec.java From litho with Apache License 2.0 | 4 votes |
@OnUpdateState static void onUpdateState(StateValue<Integer> extra, @Param int newExtra) { extra.set(newExtra); }
Example 10
Source File: FavouriteButtonSpec.java From litho-picasso with MIT License | 4 votes |
@OnUpdateState static void toggleFavourited(StateValue<Boolean> favourited) { favourited.set(!favourited.get()); }
Example 11
Source File: HorizontalScrollWithSnapComponentSpec.java From litho with Apache License 2.0 | 4 votes |
@OnCreateInitialState static void onCreateInitialState(ComponentContext c, StateValue<Integer> snapMode) { snapMode.set(SNAP_NONE); }
Example 12
Source File: BoundsAnimationComponentSpec.java From litho with Apache License 2.0 | 4 votes |
@OnUpdateState static void toggleFlag3(StateValue<Boolean> flag3) { flag3.set(!flag3.get()); }
Example 13
Source File: StateUpdateTestInnerLayoutSpec.java From litho with Apache License 2.0 | 4 votes |
@OnCreateInitialState static void onCreateInitialState( ComponentContext c, StateValue<Integer> stateValue, @Prop AtomicInteger createStateCount) { createStateCount.incrementAndGet(); stateValue.set(10); }
Example 14
Source File: EditTextSpec.java From litho with Apache License 2.0 | 4 votes |
@OnUpdateState static void updateInput(StateValue<CharSequence> input, @Param CharSequence newInput) { input.set(newInput); }
Example 15
Source File: RecyclerCollectionComponentSpec.java From litho with Apache License 2.0 | 4 votes |
@OnUpdateState static void updateLoadingState( StateValue<LoadingState> loadingState, @Param LoadingState currentLoadingState) { loadingState.set(currentLoadingState); }
Example 16
Source File: SingleComponentMovesSlowTransitionSpec.java From litho with Apache License 2.0 | 4 votes |
@OnCreateInitialState static void onCreateInitialState(ComponentContext c, StateValue<Boolean> shouldAlignStart) { shouldAlignStart.set(true); }
Example 17
Source File: ChildComponentWithStateUpdateSpec.java From litho with Apache License 2.0 | 4 votes |
@OnUpdateState public static void onUpdateState(StateValue<Integer> count) { count.set(count.get() + 1); }
Example 18
Source File: SharedElementsComponentSpec.java From litho with Apache License 2.0 | 4 votes |
@OnUpdateState static void updateState(StateValue<Boolean> landLitho) { landLitho.set(!landLitho.get()); }
Example 19
Source File: BoundsAnimationComponentSpec.java From litho with Apache License 2.0 | 4 votes |
@OnUpdateState static void toggleFlag2(StateValue<Boolean> flag2) { flag2.set(!flag2.get()); }
Example 20
Source File: StoryCardComponentSpec.java From litho with Apache License 2.0 | 4 votes |
@OnCreateInitialState static void onCreateInitialState(ComponentContext c, StateValue<Boolean> saved) { saved.set(false); }