@Override public final void setTabPreviewFadeDuration(final long duration) { Condition.INSTANCE.ensureAtLeast(duration, 0, "The duration must be at least 0"); this.tabPreviewFadeDuration = duration; }
@Override public final void setTabPreviewFadeThreshold(final long threshold) { Condition.INSTANCE.ensureAtLeast(threshold, 0, "The threshold must be at least 0"); this.tabPreviewFadeThreshold = threshold; }
/** * Creates a new animation. * * @param duration * The duration of the animation in milliseconds as a {@link Long} value or -1, if the * default duration should be used * @param interpolator * The interpolator, which should be used by the animation, as an instance of the type * {@link Interpolator} or null, if the default interpolator should be used */ protected Animation(final long duration, @Nullable final Interpolator interpolator) { Condition.INSTANCE.ensureAtLeast(duration, -1, "The duration must be at least -1"); this.duration = duration; this.interpolator = interpolator; }
/** * Creates a new drag gesture, which can be used to perform certain action when dragging in a * particular direction. * * @param threshold * The distance in pixels, the gesture must last until it is recognized, as an {@link * Integer} value. The distance must be at least 0 or -1, if the default distance should * be used * @param touchableArea * The bounds of the onscreen area, which should be taken into consideration for * recognizing the drag gesture, as an instance of the class {@link RectF} or null, if * the area should not be restricted */ protected DragGesture(final int threshold, @Nullable final RectF touchableArea) { Condition.INSTANCE.ensureAtLeast(threshold, -1, "The threshold must be at least -1"); this.threshold = threshold; this.touchableArea = touchableArea; }
/** * Creates a new drag gesture, which allows to switch between tabs, when swiping horizontally. * * @param threshold * The distance in pixels, the gesture must last until it is recognized, as an {@link * Integer} value. The distance must be at least 0 or -1, if the default distance should * be used * @param touchableArea * The bounds of the onscreen area, which should be taken into consideration for * recognizing the drag gesture, as an instance of the class {@link RectF} or null, if * the area should not be restricted * @param animationDuration * The duration of the swipe animation in milliseconds as a {@link Long} value. The * duration must be at least -1 */ private SwipeGesture(final int threshold, @Nullable final RectF touchableArea, final long animationDuration) { super(threshold, touchableArea); Condition.INSTANCE .ensureAtLeast(animationDuration, -1, "The animation duration must be at least -1"); this.animationDuration = animationDuration; }
/** * Creates a new item, which contains information about a child view of a {@link TabSwitcher}. * * @param index * The index of the item as an {@link Integer} value. The index must be at least 0 */ public AbstractItem(final int index) { Condition.INSTANCE.ensureAtLeast(index, 0, "The index must be at least 0"); this.index = index; this.view = null; this.tag = new Tag(); }
/** * Sets the threshold of the drag gestures, which are created by the builder. * * @param threshold * The threshold, which should be set, in pixels as a {@link Integer} value. The * threshold must be at least 0 or -1, if the default threshold should be used * @return The builder, this method has been called upon, as an instance of the generic type * BuilderType. The builder may not be null */ @NonNull public final BuilderType setThreshold(final int threshold) { Condition.INSTANCE.ensureAtLeast(threshold, -1, "The threshold must be at least -1"); this.threshold = threshold; return self(); }
/** * Sets the duration of the animations, which are created by the builder. * * @param duration * The duration, which should be set, in milliseconds as a {@link Long} value or -1, * if the default duration should be used * @return The builder, this method has be called upon, as an instance of the generic type * BuilderType. The builder may not be null */ @NonNull public final BuilderType setDuration(final long duration) { Condition.INSTANCE.ensureAtLeast(duration, -1, "The duration must be at least -1"); this.duration = duration; return self(); }
/** * Sets the index of the first item, which should be iterated. * * @param start * The index, which should be set, as an {@link Integer} value or -1, if all items * should be iterated * @return The builder, this method has been called upon, as an instance of the generic type * BuilderType. The builder may not be null */ @NonNull public BuilderType start(final int start) { Condition.INSTANCE.ensureAtLeast(start, -1, "The start must be at least -1"); this.start = start; return self(); }
/** * Sets the duration of the swipe animation of the gestures, which are created by the * builder. * * @param animationDuration * The duration, which should be set, in milliseconds as a {@link Long} value or -1, * if the default duration should be used * @return The builder, this method has been called upon, as an instance of the generic type * BuilderType. The builder may not be null */ public Builder setAnimationDuration(final long animationDuration) { Condition.INSTANCE.ensureAtLeast(animationDuration, -1, "The animation duration must be at least -1"); this.animationDuration = animationDuration; return self(); }
/** * Sets the duration of the animations, which are used to relocate the other tabs, when a * tab has been added or removed. * * @param relocateAnimationDuration * The duration, which should be set, in milliseconds as a {@link Long} value or -1, * if the default duration should be used * @return The builder, this method has be called upon, as an instance of the generic type * BuilderType. The builder may not be null */ @NonNull public final Builder setRelocateAnimationDuration(final long relocateAnimationDuration) { Condition.INSTANCE.ensureAtLeast(relocateAnimationDuration, -1, "The relocate animation duration must be at least -1"); this.relocateAnimationDuration = relocateAnimationDuration; return self(); }
/** * Updates the drawable to display a specific value. * * @param count * The value, which should be displayed, as an {@link Integer} value. The value must be * at least 0 */ public final void setCount(final int count) { Condition.INSTANCE.ensureAtLeast(count, 0, "The count must be at least 0"); label = Integer.toString(count); if (label.length() > 2) { label = "99+"; paint.setTextSize(textSizeSmall); } else { paint.setTextSize(textSizeNormal); } invalidateSelf(); }
/** * Creates a new swipe animation. * * @param duration * The duration of the animation in milliseconds as a {@link Long} value or -1, if the * default duration should be used * @param interpolator * The interpolator, which should be used by the animation, as an instance of the type * {@link Interpolator} or null, if the default interpolator should be used * @param direction * The direction of the swipe animation as a value of the enum {@link SwipeDirection}. * The direction may not be null * @param relocateAnimationDuration * The duration of the animations, which are used to relocate other tabs, when a tab has * been added or removed, in milliseconds as a {@link Long} value or -1, if the default * duration should be used */ private SwipeAnimation(final long duration, @Nullable final Interpolator interpolator, @NonNull final SwipeDirection direction, final long relocateAnimationDuration) { super(duration, interpolator); Condition.INSTANCE.ensureNotNull(direction, "The direction may not be null"); Condition.INSTANCE.ensureAtLeast(relocateAnimationDuration, -1, "The relocate animation duration must be at least -1"); this.direction = direction; this.relocateAnimationDuration = relocateAnimationDuration; }
/** * Sets the bounds of the onscreen area, which should be taken into consideration for * recognizing the drag gestures, which are create by the builder. drag gestures. * * @param left * The coordinate of the left edge in pixels as a {@link Float} value. The * coordinate must be at least 0 * @param top * The coordinate of the top edge in pixels as a {@link Float} value. The coordinate * must be at least 0 * @param right * The coordinate of the right edge in pixels as a {@link Float} value. The * coordinate must be greater than the coordinate of the left edge * @param bottom * The coordinate of the bottom edge in pixels as a {@link Float} value. The * coordinate must be greater than the coordinate of the top edge * @return The builder, this method has been called upon, as an instance of the generic type * BuilderType. The builder may not be null */ @NonNull public final BuilderType setTouchableArea(final float left, final float top, final float right, final float bottom) { Condition.INSTANCE.ensureAtLeast(left, 0, "The left coordinate must be at least 0"); Condition.INSTANCE.ensureAtLeast(top, 0, "The top coordinate must be at least 0"); Condition.INSTANCE.ensureGreater(right, left, "The right coordinate must be greater than " + left); Condition.INSTANCE.ensureGreater(bottom, top, "The bottom coordinate must be greater than " + top); return setTouchableArea(new RectF(left, top, right, bottom)); }
/** * Creates a new handler, which can be managed by a {@link TouchEventDispatcher} in order to * dispatch touch events to it. * * @param priority * The priority of the handler as an {@link Integer} value. The priority must be at * least {@link AbstractTouchEventHandler#MIN_PRIORITY} and at maximum {@link * AbstractTouchEventHandler#MAX_PRIORITY} * @param tabSwitcher * The tab switcher, the event handler belongs to, as an instance of the class {@link * TabSwitcher}. The tab switcher may not be null * @param dragThreshold * The threshold of the drag helper, which is used to recognize drag gestures, in pixels * as an {@link Integer} value The threshold must be at least 0 */ public AbstractTouchEventHandler(final int priority, @NonNull final TabSwitcher tabSwitcher, final int dragThreshold) { Condition.INSTANCE.ensureAtLeast(priority, MIN_PRIORITY, "The priority must be at least" + MIN_PRIORITY); Condition.INSTANCE.ensureAtMaximum(priority, MAX_PRIORITY, "The priority must be at maximum " + MAX_PRIORITY); Condition.INSTANCE.ensureNotNull(tabSwitcher, "The tab switcher may not be null"); Condition.INSTANCE.ensureAtLeast(dragThreshold, 0, "The drag threshold must be at least 0"); this.priority = priority; this.tabSwitcher = tabSwitcher; this.dragHelper = new DragHelper(0); this.dragThreshold = dragThreshold; reset(); }
Condition.INSTANCE.ensureNotNull(viewRecycler, "The view recycler may not be null"); Condition.INSTANCE.ensureNotNull(array, "The array may not be null"); Condition.INSTANCE.ensureAtLeast(firstIndex, 0, "The first index must be at least 0"); this.model = model; this.viewRecycler = viewRecycler;
Condition.INSTANCE.ensureNotNull(viewRecycler, "The view recycler may not be null"); Condition.INSTANCE.ensureNotNull(array, "The array may not be null"); Condition.INSTANCE.ensureAtLeast(firstIndex, 0, "The first index must be at least 0"); this.model = model; this.viewRecycler = viewRecycler;
/** * Initializes the iterator. * * @param reverse * True, if the items should be iterated in reverse order, false otherwise * @param start * The index of the first item, which should be iterated, as an {@link Integer} value or * -1, if all items should be iterated */ protected final void initialize(final boolean reverse, final int start) { Condition.INSTANCE.ensureAtLeast(start, -1, "The start must be at least -1"); this.reverse = reverse; this.previous = null; this.index = start != -1 ? start : (reverse ? getCount() - 1 : 0); int previousIndex = reverse ? this.index + 1 : this.index - 1; if (previousIndex >= 0 && previousIndex < getCount()) { this.current = getItem(previousIndex); } else { this.current = null; } }
/** * Sets the delay until the animation is started. * * @param startDelay * The delay, which should be set, in milliseconds as a {@link Long} value. The delay * must be at least 0 */ protected final void setStartDelay(final long startDelay) { Condition.INSTANCE.ensureAtLeast(startDelay, 0, "The start delay must be at least 0"); this.startDelay = startDelay; }
/** * Sets the radius, which should be used by the animation. * * @param radius * The radius, which should be set, in pixels as an {@link Integer} value. The radius * must be at least 0 */ protected final void setRadius(final int radius) { Condition.INSTANCE.ensureAtLeast(radius, 0, "The radius must be at least 0"); this.radius = radius; }