Animation { boolean shouldAnimate(int currentPage) { return (pageStart == pageEnd && pageStart == Page.ALL_PAGES) || pageStart <= currentPage && pageEnd >= currentPage; } Animation(@NonNull Page page); final void setInterpolator(Interpolator interpolator); abstract void onAnimate(View v, float offset, float offsetInPixel); @SuppressWarnings("unused") void onAnimateOffScreenLeft(View v, float offset, float offsetInPixel); @SuppressWarnings("unused") void onAnimateOffScreenRight(View v, float offset, float offsetInPixel); @SuppressWarnings("unused") void setAnimationListener(AnimationListener listener); static final int FULL_PAGE; }
@Test public void testShouldAnimate() throws Exception { Animation animation = new Animation(Page.singlePage(0)) { @Override public void onAnimate(View v, float offset, float offsetInPixel) { } }; assertEquals(true, animation.shouldAnimate(0)); assertEquals(false, animation.shouldAnimate(-1)); assertEquals(false, animation.shouldAnimate(2)); }