Java Code Examples for com.facebook.litho.StateValue#get()
The following examples show how to use
com.facebook.litho.StateValue#get() .
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: ToggleMoveBlocksExampleComponentSpec.java From litho with Apache License 2.0 | 5 votes |
@OnUpdateState static void updateState( StateValue<Integer> state, StateValue<Boolean> running, @Param boolean toggleRunning) { running.set(toggleRunning ? !running.get() : running.get()); if (running.get()) { state.set((state.get() + 1) % 6); } }
Example 3
Source File: BlocksSameTransitionKeyComponentSpec.java From litho with Apache License 2.0 | 5 votes |
@OnUpdateState static void updateState( StateValue<Boolean> state, StateValue<Boolean> running, StateValue<Set<String>> runningAnimations, @Param boolean toggleRunning) { if (toggleRunning && !running.get()) { running.set(true); runningAnimations.get().add(ANIM_ALPHA); runningAnimations.get().add(ANIM_X); state.set(!state.get()); } else if (!toggleRunning) { running.set(false); } }
Example 4
Source File: SimpleStateUpdateEmulatorSpec.java From litho with Apache License 2.0 | 5 votes |
@OnUpdateState static void onIncrementCount(StateValue<Integer> count) { Integer counter = count.get(); if (counter == null) { throw new RuntimeException("state value is null."); } count.set(counter + 1); }
Example 5
Source File: FullGroupSection.java From litho with Apache License 2.0 | 5 votes |
@Override protected void createInitialState(SectionContext c) { StateValue<T> state1 = new StateValue<>(); StateValue<Object> state2 = new StateValue<>(); FullGroupSectionSpec.onCreateInitialState( (SectionContext) c, (int) prop1, (StateValue<T>) state1, (StateValue<Object>) state2); mStateContainer.state1 = state1.get(); mStateContainer.state2 = state2.get(); }
Example 6
Source File: FullGroupSection.java From litho with Apache License 2.0 | 5 votes |
@Override public void updateState(StateContainer _stateContainer) { FullGroupSectionStateContainer<T> stateContainer = (FullGroupSectionStateContainer<T>) _stateContainer; StateValue<Object> state2 = new StateValue<Object>(); state2.set(stateContainer.state2); FullGroupSectionSpec.updateState(state2, mParam); stateContainer.state2 = state2.get(); }
Example 7
Source File: FullDiffSection.java From litho with Apache License 2.0 | 5 votes |
@Override protected void createInitialState(SectionContext c) { StateValue<Object> state1 = new StateValue<>(); FullDiffSectionSpec.onCreateInitialState( (SectionContext) c, (Integer) prop1, (StateValue<Object>) state1); mStateContainer.state1 = state1.get(); }
Example 8
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 9
Source File: TestMount.java From litho with Apache License 2.0 | 5 votes |
@Override protected void createInitialState(ComponentContext c) { StateValue<S> state2 = new StateValue<>(); TestMountSpec.createInitialState((ComponentContext) c, (int) prop1, (StateValue<S>) state2); if (state2.get() != null) { mStateContainer.state2 = state2.get(); } }
Example 10
Source File: TestMount.java From litho with Apache License 2.0 | 5 votes |
@Override public void updateState(StateContainer _stateContainer) { TestMountStateContainer<S> stateContainer = (TestMountStateContainer<S>) _stateContainer; StateValue<Long> state1 = new StateValue<Long>(); state1.set(stateContainer.state1); TestMountSpec.updateCurrentState(state1, mSomeParam); stateContainer.state1 = state1.get(); }
Example 11
Source File: TestLayout.java From litho with Apache License 2.0 | 5 votes |
@Override protected void createInitialState(ComponentContext c) { StateValue<S> state2 = new StateValue<>(); TestLayoutSpec.createInitialState((ComponentContext) c, (int) prop1, (StateValue<S>) state2); if (state2.get() != null) { mStateContainer.state2 = state2.get(); } }
Example 12
Source File: TestLayout.java From litho with Apache License 2.0 | 5 votes |
@Override public void updateState(StateContainer _stateContainer) { TestLayoutStateContainer<S> stateContainer = (TestLayoutStateContainer<S>) _stateContainer; StateValue<Long> state1 = new StateValue<Long>(); state1.set(stateContainer.state1); TestLayoutSpec.updateCurrentState(state1, mSomeParam); stateContainer.state1 = state1.get(); }
Example 13
Source File: HideableDataDiffSectionSpec.java From litho with Apache License 2.0 | 5 votes |
@OnUpdateState public static void onBlacklistUpdate( StateValue<HashSet> blacklistState, @Param Object modelObject, @Param EventHandler<GetUniqueIdentifierEvent> getUniqueIdentifierHandlerParam) { HashSet<Object> newSet = new HashSet<>(blacklistState.get()); newSet.add( HideableDataDiffSection.dispatchGetUniqueIdentifierEvent( getUniqueIdentifierHandlerParam, modelObject)); blacklistState.set(newSet); }