@Override public void execute() { Animation animation = mAnimationRegistry.getAnimation(mAnimationID); if (animation != null) { mNativeViewHierarchyManager.startAnimationForNativeView( mReactTag, animation, mSuccessCallback); } else { // node or animation not found // TODO(5712813): cleanup callback in JS callbacks table in case of an error throw new IllegalViewOperationException("Animation with id " + mAnimationID + " was not found"); } }
@Override public void execute() { Animation animation = mAnimationRegistry.getAnimation(mAnimationID); if (animation != null) { animation.cancel(); } }
@Test public void testAddAndRemoveAnimation() { UIManagerModule uiManagerModule = getUIManagerModule(); TestMoveDeleteHierarchy hierarchy = createMoveDeleteHierarchy(uiManagerModule); AnimationPropertyUpdater mockPropertyUpdater = mock(AnimationPropertyUpdater.class); Animation mockAnimation = spy(new AnimationStub(1000, mockPropertyUpdater)); Callback callbackMock = mock(Callback.class); int rootTag = hierarchy.rootView; uiManagerModule.createView( hierarchy.rootView, ReactViewManager.REACT_CLASS, rootTag, JavaOnlyMap.of("collapsable", false)); uiManagerModule.registerAnimation(mockAnimation); uiManagerModule.addAnimation(hierarchy.rootView, 1000, callbackMock); uiManagerModule.removeAnimation(hierarchy.rootView, 1000); uiManagerModule.onBatchComplete(); executePendingFrameCallbacks(); verify(callbackMock, times(1)).invoke(false); verify(mockAnimation).run(); verify(mockAnimation).cancel(); }
@Test public void testAddAndRemoveAnimation() { UIManagerModule uiManagerModule = getUIManagerModule(); TestMoveDeleteHierarchy hierarchy = createMoveDeleteHierarchy(uiManagerModule); AnimationPropertyUpdater mockPropertyUpdater = mock(AnimationPropertyUpdater.class); Animation mockAnimation = spy(new AnimationStub(1000, mockPropertyUpdater)); Callback callbackMock = mock(Callback.class); int rootTag = hierarchy.rootView; uiManagerModule.createView( hierarchy.rootView, ReactViewManager.REACT_CLASS, rootTag, JavaOnlyMap.of("collapsable", false)); uiManagerModule.registerAnimation(mockAnimation); uiManagerModule.addAnimation(hierarchy.rootView, 1000, callbackMock); uiManagerModule.removeAnimation(hierarchy.rootView, 1000); uiManagerModule.onBatchComplete(); executePendingChoreographerCallbacks(); verify(callbackMock, times(1)).invoke(false); verify(mockAnimation).run(); verify(mockAnimation).cancel(); }
private RegisterAnimationOperation(Animation animation) { super(animation.getAnimationID()); mAnimation = animation; }
public void enqueueRegisterAnimation(Animation animation) { mOperations.add(new RegisterAnimationOperation(animation)); }
/** * Registers a new Animation that can then be added to a View using {@link #addAnimation}. */ public void registerAnimation(Animation animation) { mOperationsQueue.enqueueRegisterAnimation(animation); }
/** * Registers a new Animation that can then be added to a View using {@link #addAnimation}. */ public void registerAnimation(Animation animation) { mUIImplementation.registerAnimation(animation); }