/** * 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(); }
/** * Sets the symbol, which should be used to separate floating point numbers for textual * representation. * * @param floatingPointSeparator * The symbol, which should be set, as an instance of the type {@link CharSequence} or * null, if the default symbol should be used. The length of the symbol must be 1 */ public final void setFloatingPointSeparator( @Nullable final CharSequence floatingPointSeparator) { if (floatingPointSeparator != null) { Condition.INSTANCE.ensureAtMaximum(floatingPointSeparator.length(), 1, "The floating point separator's length must be 1"); } this.floatingPointSeparator = floatingPointSeparator; }
/** * Sets the alpha, which should be used by the animation. * * @param alpha * The alpha, which should be set, as a {@link Float} value. The alpha must be at least * 0 and at maximum 1 */ protected final void setAlpha(final float alpha) { Condition.INSTANCE.ensureAtLeast(alpha, 0, "The alpha must be at least 0"); Condition.INSTANCE.ensureAtMaximum(alpha, 1, "The alpha must be at maximum 1"); this.alpha = alpha; }
/** * Sets the dim amount, which should be used to darken the area outside the bottom sheet. * * @param dimAmount * The dim amount, which should be set, as a {@link Float} value. The dim amount must be * at least 0 (fully transparent) and at maximum 1 (fully opaque) */ public final void setDimAmount(final float dimAmount) { Condition.INSTANCE.ensureAtLeast(dimAmount, 0, "The dim amount must be at least 0"); Condition.INSTANCE.ensureAtMaximum(dimAmount, 1, "The dim amount must be at maximum 1"); this.dimAmount = dimAmount; getWindow().getAttributes().dimAmount = dimAmount; }
@Override public final void setNumber(final int number) { Condition.INSTANCE.ensureAtMaximum(Integer.toString(number).length(), getNumberOfDigits(), "The number must have at maximum " + getNumberOfDigits() + " digits"); currentNumber = number; super.setNumber(number); }
/** * Sets the elevation of the button bar, which is shown when using the activity as a wizard. * * @param elevation * The elevation, which should be set, in dp as an {@link Integer} value. The elevation * must be at least 0 and at maximum 16 */ public final void setButtonBarElevation(final int elevation) { Condition.INSTANCE.ensureAtLeast(elevation, 0, "The elevation must be at least 0"); Condition.INSTANCE.ensureAtMaximum(elevation, ElevationUtil.MAX_ELEVATION, "The elevation must be at maximum " + ElevationUtil.MAX_ELEVATION); this.buttonBarElevation = elevation; adaptButtonBarElevation(); }
/** * Sets the elevation of the activity's toolbar. * * @param elevation * The elevation, which should be set, in dp as an {@link Integer} value. The elevation * must be at least 0 and at maximum 16 */ public final void setToolbarElevation(final int elevation) { Condition.INSTANCE.ensureAtLeast(elevation, 0, "The elevation must be at least 0"); Condition.INSTANCE.ensureAtMaximum(elevation, ElevationUtil.MAX_ELEVATION, "The elevation must at maximum " + ElevationUtil.MAX_ELEVATION); this.toolbarElevation = elevation; adaptToolbarElevation(); }
/** * Sets the elevation of the view group, which contains the button, which allows to restore the * preferences' default values. * * @param elevation * The elevation, which should be set, in dp as an {@link Integer} value. The elevation * must be at least 1 and at maximum 16 */ public final void setButtonBarElevation(final int elevation) { Condition.INSTANCE.ensureAtLeast(elevation, 0, "The elevation must be at least 0"); Condition.INSTANCE.ensureAtMaximum(elevation, 16, "The elevation must be at maximum 16"); this.buttonBarElevation = elevation; adaptButtonBarElevation(); }
/** * Sets the elevation of the toolbar, which is used to show the bread crumb of the currently * selected navigation preference, when using the split screen layout. * * @param elevation * The elevation, which should be set, in dp as an {@link Integer} value. The elevation * must be at least 0 and at maximum 16 */ public final void setBreadCrumbElevation(final int elevation) { Condition.INSTANCE.ensureAtLeast(elevation, 0, "The elevation must be at least 0"); Condition.INSTANCE.ensureAtMaximum(elevation, ElevationUtil.MAX_ELEVATION, "The elevation must at maximum " + ElevationUtil.MAX_ELEVATION); this.breadCrumbElevation = elevation; adaptBreadCrumbElevation(); }
/** * Sets the elevation of the card view, which contains the currently shown prefernce fragment, * when using the split screen layout. * * @param elevation * The elevation, which should be set, in dp as an {@link Integer} value. The elevation * must be at least 0 and at maximum 16 */ public final void setCardViewElevation(final int elevation) { Condition.INSTANCE.ensureAtLeast(elevation, 0, "The elevation must be at least 0"); Condition.INSTANCE.ensureAtMaximum(elevation, ElevationUtil.MAX_ELEVATION, "The elevation must be at maximum " + ElevationUtil.MAX_ELEVATION); this.cardViewElevation = elevation; adaptCardViewElevation(); }
/** * Sets the sensitivity, which specifies the distance after which dragging has an effect on the * bottom sheet, in relation to an internal value range. * * @param dragSensitivity * The drag sensitivity, which should be set, as a {@link Float} value. The drag * sensitivity must be at lest 0 and at maximum 1 */ public final void setDragSensitivity(final float dragSensitivity) { Condition.INSTANCE .ensureAtLeast(dragSensitivity, 0, "The drag sensitivity must be at least 0"); Condition.INSTANCE .ensureAtMaximum(dragSensitivity, 1, "The drag sensitivity must be at maximum 1"); this.dragSensitivity = dragSensitivity; adaptDragSensitivity(); }
@Override public final void setNumber(final int number) { Condition.INSTANCE.ensureAtLeast(number, getMinNumber(), "The number must be at least the minimum number"); Condition.INSTANCE.ensureAtMaximum(number, getMaxNumber(), "The number must be at maximum the maximum number"); int roundedNumber = adaptToStepSize(number); this.currentIndex = roundedNumber; super.setNumber(roundedNumber); }
/** * Sets the step size, the number should be increased or decreased by when moving the selector * wheel. * * @param stepSize * The step size, which should be set, as an {@link Integer} value. The value must be * between at least 1 and at maximum the value of the method * <code>getRange():int</code> */ public final void setStepSize(final int stepSize) { Condition.INSTANCE.ensureAtLeast(stepSize, 1, "The step size must be at least 1"); Condition.INSTANCE.ensureAtMaximum(stepSize, getRange(), "The step size must be at maximum the range"); this.stepSize = stepSize; setNumber(adaptToStepSize(getNumber())); }
/** * Sets the step size, the value should be increased or decreased by, when moving the seek bar. * * @param stepSize * The step size, which should be set, as an {@link Integer} value. The value must be at * least 1 and at maximum the value of the method <code>getRange():int</code> or -1, if * the preference should allow to select a value from a continuous range */ public final void setStepSize(final int stepSize) { if (stepSize != -1) { Condition.INSTANCE.ensureAtLeast(stepSize, 1, "The step size must be at least 1"); Condition.INSTANCE.ensureAtMaximum(stepSize, getRange(), "The step size must be at maximum the range"); } this.stepSize = stepSize; setValue(adaptToStepSize(getValue())); }
/** * Sets the current value of the preference. By setting a value, it will be persisted. * * @param value * The value, which should be set, as a {@link Float} value. The value must be between * the minimum and the maximum value, the preference allows to select */ public final void setValue(final Float value) { Condition.INSTANCE.ensureAtLeast(value, getMinValue(), "The value must be at least the minimum value"); Condition.INSTANCE.ensureAtMaximum(value, getMaxValue(), "The value must be at maximum the maximum value"); float roundedValue = adaptToStepSize(roundToDecimals(value)); if (this.value != roundedValue) { this.value = roundedValue; this.currentValue = roundedValue; persistFloat(roundedValue); notifyChanged(); } }