dynamic-animation/src/androidTest/java/androidx/dynamicanimation/tests/SpringTests.java
@Test
    public void testRemoveListeners() {
        final SpringAnimation anim = new SpringAnimation(mView1, DynamicAnimation.ALPHA, 0.5f);
        DynamicAnimation.OnAnimationEndListener endListener = mock(
                DynamicAnimation.OnAnimationEndListener.class);
        DynamicAnimation.OnAnimationEndListener removedEndListener = mock(
                DynamicAnimation.OnAnimationEndListener.class);
        DynamicAnimation.OnAnimationUpdateListener updateListener = mock(
                DynamicAnimation.OnAnimationUpdateListener.class);
        DynamicAnimation.OnAnimationUpdateListener removedUpdateListener = mock(
                DynamicAnimation.OnAnimationUpdateListener.class);

        anim.addEndListener(removedEndListener);
        anim.addEndListener(endListener);
        anim.removeEndListener(removedEndListener);

        anim.addUpdateListener(removedUpdateListener);
        anim.addUpdateListener(updateListener);
        anim.removeUpdateListener(removedUpdateListener);

        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                anim.start();
            }
        });

        verify(endListener, timeout(1000)).onAnimationEnd(anim, false, 0.5f, 0f);
        verify(updateListener, atLeast(2)).onAnimationUpdate(eq(anim), any(float.class),
                any(float.class));

        verifyZeroInteractions(removedEndListener);
        verifyZeroInteractions(removedUpdateListener);
    }
/**
     * Remove an update listener and an end listener, and check that there are no interaction after
     * removal.
     */
Remove an update listener and an end listener, and check that there are no interaction after
removal.
Remove an update listener and an end listener and check that there are no interaction after removal .
@Test
    public void testRemoveListeners() {
        final SpringAnimation anim = new SpringAnimation(mView1, DynamicAnimation.ALPHA, 0.5f);
        DynamicAnimation.OnAnimationEndListener endListener = mock(
                DynamicAnimation.OnAnimationEndListener.class);
        DynamicAnimation.OnAnimationEndListener removedEndListener = mock(
                DynamicAnimation.OnAnimationEndListener.class);
        DynamicAnimation.OnAnimationUpdateListener updateListener = mock(
                DynamicAnimation.OnAnimationUpdateListener.class);
        DynamicAnimation.OnAnimationUpdateListener removedUpdateListener = mock(
                DynamicAnimation.OnAnimationUpdateListener.class);
        anim.addEndListener(removedEndListener);
        anim.addEndListener(endListener);
        anim.removeEndListener(removedEndListener);
        anim.addUpdateListener(removedUpdateListener);
        anim.addUpdateListener(updateListener);
        anim.removeUpdateListener(removedUpdateListener);
        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                anim.start();
            }
        });
        verify(endListener, timeout(1000)).onAnimationEnd(anim, false, 0.5f, 0f);
        verify(updateListener, atLeast(2)).onAnimationUpdate(eq(anim), any(float.class),
                any(float.class));
        verifyZeroInteractions(removedEndListener);
        verifyZeroInteractions(removedUpdateListener);
    }
@ Test public void testRemoveListeners ( ) { final SpringAnimation anim = new SpringAnimation ( mView1 , DynamicAnimation . ALPHA , 0.5f ) ; DynamicAnimation . OnAnimationEndListener endListener = mock ( DynamicAnimation . OnAnimationEndListener . class ) ; DynamicAnimation . OnAnimationEndListener removedEndListener = mock ( DynamicAnimation . OnAnimationEndListener . class ) ; DynamicAnimation . OnAnimationUpdateListener updateListener = mock ( DynamicAnimation . OnAnimationUpdateListener . class ) ; DynamicAnimation . OnAnimationUpdateListener removedUpdateListener = mock ( DynamicAnimation . OnAnimationUpdateListener . class ) ; anim . addEndListener ( removedEndListener ) ; anim . addEndListener ( endListener ) ; anim . removeEndListener ( removedEndListener ) ; anim . addUpdateListener ( removedUpdateListener ) ; anim . addUpdateListener ( updateListener ) ; anim . removeUpdateListener ( removedUpdateListener ) ; InstrumentationRegistry . getInstrumentation ( ) . runOnMainSync ( new Runnable ( ) { @ Override public void run ( ) { anim . start ( ) ; } } ) ; verify ( endListener , timeout ( 1000 ) ) . onAnimationEnd ( anim , false , 0.5f , 0f ) ; verify ( updateListener , atLeast ( 2 ) ) . onAnimationUpdate ( eq ( anim ) , any ( float . class ) , any ( float . class ) ) ; verifyZeroInteractions ( removedEndListener ) ; verifyZeroInteractions ( removedUpdateListener ) ; }
Remove an update listener and an end listener, and check that there are no interaction after
 removal.
Remove an update listener and an end listener and check that there are no interaction after removal .