java.lang.Object
android.view.View
com.google.android.material.slider.Slider
com.pranavpandey.android.dynamic.support.widget.DynamicSlider
All Implemented Interfaces:
Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, BaseWidget, DynamicProgressWidget, DynamicWidget
Direct Known Subclasses:
DynamicHueSlider

public class DynamicSlider extends Slider implements DynamicProgressWidget
A Slider to apply DynamicTheme according to the supplied parameters.
  • Field Details

    • mColorType

      protected int mColorType
      Color type applied to this view.
      See Also:
    • mContrastWithColorType

      protected int mContrastWithColorType
      Background color type for this view so that it will remain in contrast with this color type.
    • mColor

      @ColorInt protected int mColor
      Color applied to this view.
    • mAppliedColor

      @ColorInt protected int mAppliedColor
      Color applied to this view after considering the background aware properties.
    • mContrastWithColor

      @ColorInt protected int mContrastWithColor
      Background color for this view so that it will remain in contrast with this color.
    • mBackgroundAware

      protected int mBackgroundAware
      The background aware functionality to change this view color according to the background. It was introduced to provide better legibility for colored views and to avoid dark view on dark background like situations.

      If this is enabled then, it will check for the contrast color and do color calculations according to that color so that this text view will always be visible on that background. If no contrast color is found then, it will take the default background color.

      See Also:
    • mContrast

      protected int mContrast
      Minimum contrast value to generate contrast color for the background aware functionality.
  • Constructor Details

  • Method Details

    • loadFromAttributes

      public void loadFromAttributes(@Nullable AttributeSet attrs)
      Description copied from interface: BaseWidget
      Load values from the supplied attribute set.
      Specified by:
      loadFromAttributes in interface BaseWidget
      Parameters:
      attrs - The supplied attribute set to load the values.
    • initialize

      public void initialize()
      Description copied from interface: BaseWidget
      Initialize this widget by setting color type. If it is background aware then, background color will also taken into account while setting the color filter.
      Specified by:
      initialize in interface BaseWidget
      See Also:
    • getColorType

      public int getColorType()
      Description copied from interface: DynamicWidget
      Returns the color type applied to this widget.
      Specified by:
      getColorType in interface DynamicWidget
      Returns:
      The color type applied to this widget.
      See Also:
    • setColorType

      public void setColorType(int colorType)
      Description copied from interface: DynamicWidget
      Set the color type to this widget.
      Specified by:
      setColorType in interface DynamicWidget
      Parameters:
      colorType - The color type for this widget.
      See Also:
    • getContrastWithColorType

      public int getContrastWithColorType()
      Description copied from interface: DynamicWidget
      Returns the contrast with color type applied to this widget.
      Specified by:
      getContrastWithColorType in interface DynamicWidget
      Returns:
      The contrast with color type applied to this widget.
      See Also:
    • setContrastWithColorType

      public void setContrastWithColorType(int contrastWithColorType)
      Description copied from interface: DynamicWidget
      Set the contrast with color type to this widget.
      Specified by:
      setContrastWithColorType in interface DynamicWidget
      Parameters:
      contrastWithColorType - The contrast with color type for this widget.
      See Also:
    • getColor

      @ColorInt public int getColor(boolean resolve)
      Description copied from interface: DynamicWidget
      Returns the value of color applied to this widget.
      Specified by:
      getColor in interface DynamicWidget
      Parameters:
      resolve - true to resolve the applied color.
      Returns:
      The value of color applied to this widget.
    • getColor

      @ColorInt public int getColor()
      Description copied from interface: DynamicWidget
      Returns the value of color applied to this widget.
      Specified by:
      getColor in interface DynamicWidget
      Returns:
      The value of color applied to this widget.
    • setColor

      public void setColor(@ColorInt int color)
      Description copied from interface: DynamicWidget
      Set the value of color for this widget.
      Specified by:
      setColor in interface DynamicWidget
      Parameters:
      color - Color for this widget.
    • getContrastWithColor

      @ColorInt public int getContrastWithColor()
      Description copied from interface: DynamicWidget
      Returns the value of contrast with color applied to this widget.
      Specified by:
      getContrastWithColor in interface DynamicWidget
      Returns:
      The value of contrast with color applied to this widget.
    • setContrastWithColor

      public void setContrastWithColor(@ColorInt int contrastWithColor)
      Description copied from interface: DynamicWidget
      Set the value of contrast with color for this widget.
      Specified by:
      setContrastWithColor in interface DynamicWidget
      Parameters:
      contrastWithColor - Contrast with color for this widget.
    • getBackgroundAware

      public int getBackgroundAware()
      Description copied from interface: DynamicWidget
      Returns the background aware functionality used by this widget.
      Specified by:
      getBackgroundAware in interface DynamicWidget
      Returns:
      The background aware functionality used by this widget.
    • isBackgroundAware

      public boolean isBackgroundAware()
      Description copied from interface: DynamicWidget
      Checks whether the background aware functionality is enabled.
      Specified by:
      isBackgroundAware in interface DynamicWidget
      Returns:
      true if this widget changes color according to the background.
    • setBackgroundAware

      public void setBackgroundAware(int backgroundAware)
      Description copied from interface: DynamicWidget
      Set the value to make this widget background aware or not.
      Specified by:
      setBackgroundAware in interface DynamicWidget
      Parameters:
      backgroundAware - The background aware functionality to be set.
    • getContrast

      public int getContrast(boolean resolve)
      Description copied from interface: DynamicWidget
      Get the contrast value used by this widget.
      Specified by:
      getContrast in interface DynamicWidget
      Parameters:
      resolve - true to resolve auto contrast.
      Returns:
      The contrast value used by this widget.
    • getContrast

      public int getContrast()
      Description copied from interface: DynamicWidget
      Get the contrast value used by this widget.
      Specified by:
      getContrast in interface DynamicWidget
      Returns:
      The contrast value used by this widget.
    • getContrastRatio

      public float getContrastRatio()
      Description copied from interface: DynamicWidget
      Returns the contrast ratio for by this widget.
      Specified by:
      getContrastRatio in interface DynamicWidget
      Returns:
      The contrast ratio for by this widget.
    • setContrast

      public void setContrast(int contrast)
      Description copied from interface: DynamicWidget
      Set the contrast value used for this widget.
      Specified by:
      setContrast in interface DynamicWidget
      Parameters:
      contrast - The contrast value to be set.
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from interface: DynamicWidget
      Override this method to handle state changes for this widget.

      For example, change alpha according to the enabled or disabled state of this widget.

      Specified by:
      setEnabled in interface DynamicWidget
      Parameters:
      enabled - true if this widget is enabled and can receive click events.
    • setColor

      public void setColor()
      Description copied from interface: DynamicWidget
      Set color for this widget according to the supplied values.
      Specified by:
      setColor in interface DynamicWidget
    • setProgressBarColor

      public void setProgressBarColor()
      Description copied from interface: DynamicProgressWidget
      Set progress bar color according to the supplied values.
      Specified by:
      setProgressBarColor in interface DynamicProgressWidget
    • setThumbColor

      public void setThumbColor()
      Description copied from interface: DynamicProgressWidget
      Set thumb color according to the supplied values.
      Specified by:
      setThumbColor in interface DynamicProgressWidget
    • getValueFrom

      public float getValueFrom()
    • setValueFrom

      public void setValueFrom(float arg0)
    • getValueTo

      public float getValueTo()
    • setValueTo

      public void setValueTo(float arg0)
    • getStepSize

      public float getStepSize()
    • setStepSize

      public void setStepSize(float arg0)
    • getFocusedThumbIndex

      public int getFocusedThumbIndex()
    • setFocusedThumbIndex

      public void setFocusedThumbIndex(int arg0)
    • setActiveThumbIndex

      protected void setActiveThumbIndex(int arg0)
    • getActiveThumbIndex

      public int getActiveThumbIndex()
    • addOnChangeListener

      public void addOnChangeListener(@NonNull Slider.OnChangeListener arg0)
    • removeOnChangeListener

      public void removeOnChangeListener(@NonNull Slider.OnChangeListener arg0)
    • clearOnChangeListeners

      public void clearOnChangeListeners()
    • addOnSliderTouchListener

      public void addOnSliderTouchListener(@NonNull Slider.OnSliderTouchListener arg0)
    • removeOnSliderTouchListener

      public void removeOnSliderTouchListener(@NonNull Slider.OnSliderTouchListener arg0)
    • clearOnSliderTouchListeners

      public void clearOnSliderTouchListeners()
    • hasLabelFormatter

      public boolean hasLabelFormatter()
    • setLabelFormatter

      public void setLabelFormatter(@Nullable LabelFormatter arg0)
    • getThumbElevation

      public float getThumbElevation()
    • setThumbElevation

      public void setThumbElevation(float arg0)
    • setThumbElevationResource

      public void setThumbElevationResource(@DimenRes int arg0)
    • getThumbRadius

      @Px public int getThumbRadius()
    • setThumbRadius

      public void setThumbRadius(@IntRange(from=0L) @Px int arg0)
    • setThumbRadiusResource

      public void setThumbRadiusResource(@DimenRes int arg0)
    • getThumbWidth

      @Px public int getThumbWidth()
    • setThumbWidth

      public void setThumbWidth(@IntRange(from=0L) @Px int arg0)
    • setThumbWidthResource

      public void setThumbWidthResource(@DimenRes int arg0)
    • getThumbHeight

      @Px public int getThumbHeight()
    • setThumbHeight

      public void setThumbHeight(@IntRange(from=0L) @Px int arg0)
    • setThumbHeightResource

      public void setThumbHeightResource(@DimenRes int arg0)
    • setThumbStrokeColor

      public void setThumbStrokeColor(@Nullable ColorStateList arg0)
    • setThumbStrokeColorResource

      public void setThumbStrokeColorResource(@ColorRes int arg0)
    • getThumbStrokeColor

      public ColorStateList getThumbStrokeColor()
    • setThumbStrokeWidth

      public void setThumbStrokeWidth(float arg0)
    • setThumbStrokeWidthResource

      public void setThumbStrokeWidthResource(@DimenRes int arg0)
    • getThumbStrokeWidth

      public float getThumbStrokeWidth()
    • getHaloRadius

      @Px public int getHaloRadius()
    • setHaloRadius

      public void setHaloRadius(@IntRange(from=0L) @Px int arg0)
    • setHaloRadiusResource

      public void setHaloRadiusResource(@DimenRes int arg0)
    • getLabelBehavior

      public int getLabelBehavior()
    • setLabelBehavior

      public void setLabelBehavior(int arg0)
    • getTrackSidePadding

      @Px public int getTrackSidePadding()
    • getTrackWidth

      @Px public int getTrackWidth()
    • getTrackHeight

      @Px public int getTrackHeight()
    • setTrackHeight

      public void setTrackHeight(@IntRange(from=0L) @Px int arg0)
    • getTickActiveRadius

      @Px public int getTickActiveRadius()
    • setTickActiveRadius

      public void setTickActiveRadius(@IntRange(from=0L) @Px int arg0)
    • getTickInactiveRadius

      @Px public int getTickInactiveRadius()
    • setTickInactiveRadius

      public void setTickInactiveRadius(@IntRange(from=0L) @Px int arg0)
    • getHaloTintList

      @NonNull public ColorStateList getHaloTintList()
    • setHaloTintList

      public void setHaloTintList(@NonNull ColorStateList arg0)
    • getThumbTintList

      @NonNull public ColorStateList getThumbTintList()
    • setThumbTintList

      public void setThumbTintList(@NonNull ColorStateList arg0)
    • getTickTintList

      @NonNull public ColorStateList getTickTintList()
    • setTickTintList

      public void setTickTintList(@NonNull ColorStateList arg0)
    • getTickActiveTintList

      @NonNull public ColorStateList getTickActiveTintList()
    • setTickActiveTintList

      public void setTickActiveTintList(@NonNull ColorStateList arg0)
    • getTickInactiveTintList

      @NonNull public ColorStateList getTickInactiveTintList()
    • setTickInactiveTintList

      public void setTickInactiveTintList(@NonNull ColorStateList arg0)
    • isTickVisible

      public boolean isTickVisible()
    • setTickVisible

      public void setTickVisible(boolean arg0)
    • getTrackTintList

      @NonNull public ColorStateList getTrackTintList()
    • setTrackTintList

      public void setTrackTintList(@NonNull ColorStateList arg0)
    • getTrackActiveTintList

      @NonNull public ColorStateList getTrackActiveTintList()
    • setTrackActiveTintList

      public void setTrackActiveTintList(@NonNull ColorStateList arg0)
    • getTrackInactiveTintList

      @NonNull public ColorStateList getTrackInactiveTintList()
    • setTrackInactiveTintList

      public void setTrackInactiveTintList(@NonNull ColorStateList arg0)
    • getThumbTrackGapSize

      public int getThumbTrackGapSize()
    • setThumbTrackGapSize

      public void setThumbTrackGapSize(@Px int arg0)
    • getTrackStopIndicatorSize

      public int getTrackStopIndicatorSize()
    • setTrackStopIndicatorSize

      public void setTrackStopIndicatorSize(@Px int arg0)
    • getTrackInsideCornerSize

      public int getTrackInsideCornerSize()
    • setTrackInsideCornerSize

      public void setTrackInsideCornerSize(@Px int arg0)
    • onVisibilityChanged

      protected void onVisibilityChanged(@NonNull View arg0, int arg1)
      Overrides:
      onVisibilityChanged in class View
    • onAttachedToWindow

      protected void onAttachedToWindow()
      Overrides:
      onAttachedToWindow in class View
    • onDetachedFromWindow

      protected void onDetachedFromWindow()
      Overrides:
      onDetachedFromWindow in class View
    • onMeasure

      protected void onMeasure(int arg0, int arg1)
      Overrides:
      onMeasure in class View
    • onSizeChanged

      protected void onSizeChanged(int arg0, int arg1, int arg2, int arg3)
      Overrides:
      onSizeChanged in class View
    • onDraw

      protected void onDraw(@NonNull Canvas arg0)
      Overrides:
      onDraw in class View
    • onTouchEvent

      public boolean onTouchEvent(@NonNull MotionEvent arg0)
      Overrides:
      onTouchEvent in class View
    • setSeparationUnit

      protected void setSeparationUnit(int arg0)
    • getMinSeparation

      protected float getMinSeparation()
    • drawableStateChanged

      protected void drawableStateChanged()
      Overrides:
      drawableStateChanged in class View
    • onKeyDown

      public boolean onKeyDown(int arg0, @NonNull KeyEvent arg1)
      Specified by:
      onKeyDown in interface KeyEvent.Callback
      Overrides:
      onKeyDown in class View
    • onKeyUp

      public boolean onKeyUp(int arg0, @NonNull KeyEvent arg1)
      Specified by:
      onKeyUp in interface KeyEvent.Callback
      Overrides:
      onKeyUp in class View
    • onFocusChanged

      protected void onFocusChanged(boolean arg0, int arg1, @Nullable Rect arg2)
      Overrides:
      onFocusChanged in class View
    • getAccessibilityClassName

      @NonNull public CharSequence getAccessibilityClassName()
      Overrides:
      getAccessibilityClassName in class View
    • dispatchHoverEvent

      public boolean dispatchHoverEvent(@NonNull MotionEvent arg0)
      Overrides:
      dispatchHoverEvent in class View
    • dispatchKeyEvent

      public boolean dispatchKeyEvent(@NonNull KeyEvent arg0)
      Overrides:
      dispatchKeyEvent in class View
    • onSaveInstanceState

      protected Parcelable onSaveInstanceState()
      Overrides:
      onSaveInstanceState in class View
    • onRestoreInstanceState

      protected void onRestoreInstanceState(Parcelable arg0)
      Overrides:
      onRestoreInstanceState in class View