@Override public final void onAllTabsAdded(final int index, @NonNull final Tab[] tabs, final int previousSelectedTabIndex, final int selectedTabIndex, final boolean selectionChanged, @NonNull final Animation animation) { Condition.INSTANCE.ensureTrue(animation instanceof SwipeAnimation, animation.getClass().getSimpleName() + " not supported for adding multiple tabs"); getLogger().logInfo(getClass(), "Added " + tabs.length + " tabs at index " + index + " using a " + animation.getClass().getSimpleName()); addAllTabs(index, tabs, animation); }
@Override public final int getTabSwitcherPadding(@NonNull final Axis axis, final int gravity) { Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null"); Condition.INSTANCE .ensureTrue(gravity == Gravity.START || gravity == Gravity.END, "Invalid gravity"); if (axis == Axis.DRAGGING_AXIS) { return gravity == Gravity.START ? getTabSwitcher().getPaddingLeft() : getTabSwitcher().getPaddingRight(); } else { return gravity == Gravity.START ? getTabSwitcher().getPaddingTop() : getTabSwitcher().getPaddingBottom(); } }
@Override public final void onTabAdded(final int index, @NonNull final Tab tab, final int previousSelectedTabIndex, final int selectedTabIndex, final boolean selectionChanged, final boolean switcherVisibilityChanged, @NonNull final Animation animation) { getLogger().logInfo(getClass(), "Added tab at index " + index + " using a " + animation.getClass().getSimpleName()); if (animation instanceof PeekAnimation && getModel().getCount() > 1) { Condition.INSTANCE.ensureTrue(switcherVisibilityChanged, animation.getClass().getSimpleName() + " not supported when the tab switcher is shown"); PeekAnimation peekAnimation = (PeekAnimation) animation; AbstractItem item = TabItem.create(getModel(), 0, tab); inflateView(item, createPeekLayoutListener(item, peekAnimation)); } else if (animation instanceof RevealAnimation && switcherVisibilityChanged) { AbstractItem item = TabItem.create(getModel(), 0, tab); RevealAnimation revealAnimation = (RevealAnimation) animation; inflateView(item, createRevealLayoutListener(item, revealAnimation)); } else { addAllTabs(index, new Tab[]{tab}, animation); } adaptEmptyView( getModel().isSwitcherShown() ? getModel().getEmptyViewAnimationDuration() : 0); }
@Override public final int getTabSwitcherPadding(@NonNull final Axis axis, final int gravity) { Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null"); Condition.INSTANCE .ensureTrue(gravity == Gravity.START || gravity == Gravity.END, "Invalid gravity"); if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) { return gravity == Gravity.START ? getTabSwitcher().getPaddingTop() : getTabSwitcher().getPaddingBottom(); } else { return gravity == Gravity.START ? getTabSwitcher().getPaddingLeft() : getTabSwitcher().getPaddingRight(); } }
@Override public final void onAllTabsRemoved(@NonNull final Tab[] tabs, @NonNull final Animation animation) { Condition.INSTANCE.ensureTrue(animation instanceof SwipeAnimation, animation.getClass().getSimpleName() + " not supported for removing tabs "); getLogger().logInfo(getClass(),
final boolean selectionChanged, @NonNull final Animation animation) { Condition.INSTANCE.ensureTrue(animation instanceof SwipeAnimation, animation.getClass().getSimpleName() + " not supported for removing tabs"); getLogger().logInfo(getClass(), "Removed tab at index " + index + " using a " +
/** * Creates a new scrollable area. * * @param top * The top-most area, which should be scrollable, as a value of the enum {@link Area} or * null, if no area should be scrollable * @param bottom * The bottom-most area, which should be scrollable, as a value of the enum {@link * Area}. If the top-most area is null, the bottom-most are must be null as well. The * index of the bottom-most area must be at least the index of the top-most area */ private ScrollableArea(final Area top, final Area bottom) { if (top != null) { Condition.INSTANCE.ensureNotNull(bottom, "If the top-most area is not null, the bottom-most area may neither be null"); Condition.INSTANCE.ensureAtLeast(bottom.getIndex(), top.getIndex(), "The index of the bottom-most area must be at least the index of the top-most area"); } else { Condition.INSTANCE.ensureTrue(bottom == null, "If the top-most area is null, the bottom-most area must be null as well"); } this.topScrollableArea = top; this.bottomScrollableArea = bottom; }
/** * Initializes the activity's toolbar. */ private void initializeToolbar() { Condition.INSTANCE.ensureTrue(getSupportActionBar() == null, "An action bar is already attached to the activity. Use the theme " + "\"@style/Theme.MaterialComponents.NoActionBar\" or " + "\"@style/Theme.MaterialComponents.Light.NoActionBar\" as the activity's theme", IllegalStateException.class); if (isSplitScreen()) { toolbarLarge.setVisibility(View.VISIBLE); } else { toolbar.setVisibility(View.VISIBLE); } setSupportActionBar(toolbar); resetTitle(); }