RequireScrollMixin implements Mixin { public void requireScrollWithNavigationBar(@NonNull final NavigationBar navigationBar) { setOnRequireScrollStateChangedListener( new OnRequireScrollStateChangedListener() { @Override public void onRequireScrollStateChanged(boolean scrollNeeded) { navigationBar.getMoreButton() .setVisibility(scrollNeeded ? View.VISIBLE : View.GONE); navigationBar.getNextButton() .setVisibility(scrollNeeded ? View.GONE : View.VISIBLE); } }); navigationBar.getMoreButton().setOnClickListener(createOnClickListener(null)); requireScroll(); } RequireScrollMixin(@NonNull TemplateLayout templateLayout); void setScrollHandlingDelegate(@NonNull ScrollHandlingDelegate delegate); void setOnRequireScrollStateChangedListener(
            @Nullable OnRequireScrollStateChangedListener listener); OnRequireScrollStateChangedListener getOnRequireScrollStateChangedListener(); OnClickListener createOnClickListener(@Nullable final OnClickListener listener); void requireScrollWithNavigationBar(@NonNull final NavigationBar navigationBar); void requireScrollWithButton(
            @NonNull Button button,
            @StringRes int moreText,
            @Nullable OnClickListener onClickListener); void requireScrollWithButton(
            @NonNull final Button button,
            final CharSequence moreText,
            @Nullable OnClickListener onClickListener); boolean isScrollingRequired(); void requireScroll();  }
@Test public void testRequireScrollWithNavigationBar() { final NavigationBar navigationBar = new NavigationBar(application); mRequireScrollMixin.requireScrollWithNavigationBar(navigationBar); mRequireScrollMixin.notifyScrollabilityChange(true); assertEquals("More button should be visible", View.VISIBLE, navigationBar.getMoreButton().getVisibility()); assertEquals("Next button should be hidden", View.GONE, navigationBar.getNextButton().getVisibility()); navigationBar.getMoreButton().performClick(); verify(mDelegate).pageScrollDown(); mRequireScrollMixin.notifyScrollabilityChange(false); assertEquals("More button should be hidden", View.GONE, navigationBar.getMoreButton().getVisibility()); assertEquals("Next button should be visible", View.VISIBLE, navigationBar.getNextButton().getVisibility()); }