Class DynamicSliderPreference

All Implemented Interfaces:
SharedPreferences.OnSharedPreferenceChangeListener, Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, ViewManager, ViewParent, BaseWidget, DynamicTintWidget, DynamicWidget
Direct Known Subclasses:
DynamicSliderCompact, DynamicSliderFloat

public class DynamicSliderPreference extends DynamicSpinnerPreference
A DynamicSpinnerPreference to provide the functionality of a slider preference with control buttons to modify the value.
  • Field Details

    • DEFAULT_MIN_VALUE

      public static final int DEFAULT_MIN_VALUE
      Default value for the minimum seek value.
      See Also:
    • DEFAULT_MAX_VALUE

      public static final int DEFAULT_MAX_VALUE
      Default value for the maximum seek value.
      See Also:
    • DEFAULT_SEEK_INTERVAL

      public static final int DEFAULT_SEEK_INTERVAL
      Default value for the seek interval.
      See Also:
    • DEFAULT_SEEK_CONTROLS

      public static final boolean DEFAULT_SEEK_CONTROLS
      Default value for the seek controls.
      See Also:
    • DEFAULT_MAX_TICK_THRESHOLD

      public static final int DEFAULT_MAX_TICK_THRESHOLD
      Default maximum threshold to enable tick.
      See Also:
  • Constructor Details

  • Method Details

    • onLoadAttributes

      protected void onLoadAttributes(@Nullable AttributeSet attrs)
      Description copied from class: DynamicView
      Load values from the supplied attribute set.
      Overrides:
      onLoadAttributes in class DynamicSpinnerPreference
      Parameters:
      attrs - The attribute set to load the values.
    • getLayoutRes

      @LayoutRes protected int getLayoutRes()
      Description copied from class: DynamicView
      This method will be called to get the layout resource for this view.

      Supply the view layout resource here to do the inflation.

      Overrides:
      getLayoutRes in class DynamicSimplePreference
      Returns:
      The layout resource for this view.
    • onInflate

      protected void onInflate()
      Description copied from class: DynamicView
      This method will be called after loading the attributed.

      Initialize the view layout here.

      Overrides:
      onInflate in class DynamicSpinnerPreference
    • getPreferenceKey

      @Nullable public String getPreferenceKey()
      Description copied from class: DynamicPreference
      Get the shared preferences key used by this preference.
      Overrides:
      getPreferenceKey in class DynamicPreference
      Returns:
      The shared preferences key used by this preference.
    • getAltPreferenceKey

      @Nullable public String getAltPreferenceKey()
      Description copied from class: DynamicPreference
      Get the shared preferences key for alternate preference.
      Overrides:
      getAltPreferenceKey in class DynamicPreference
      Returns:
      The shared preferences key for alternate preference.
    • onUpdate

      protected void onUpdate()
      Description copied from class: DynamicView
      This method will be called whenever there is a change in the view attributes or parameters.

      It is better to do any real time calculation like updating the value string or checked state in this method.

      Overrides:
      onUpdate in class DynamicSpinnerPreference
    • onEnabled

      protected void onEnabled(boolean enabled)
      Description copied from class: DynamicView
      This method will be called whenever there is a change in the view state.

      Either enabled or disabled, other views like icon, title, color, etc. must be updated here to reflect the overall view state.

      Overrides:
      onEnabled in class DynamicSimplePreference
      Parameters:
      enabled - true if this view is enabled and can receive click events.
    • 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
      Overrides:
      setColor in class DynamicFrameLayout
      Parameters:
      color - Color for this widget.
    • 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
      Overrides:
      setColor in class DynamicSimplePreference
    • isSeekEnabled

      public boolean isSeekEnabled()
      Returns whether the slider is enabled.
      Returns:
      true if slider is enabled.
    • setSeekEnabled

      public void setSeekEnabled(boolean seekEnabled)
      Enable or disable the slider.
      Parameters:
      seekEnabled - true to enable the slider.
    • setTickVisible

      public void setTickVisible(boolean tickVisible)
      Enable or disable the slider tick marks.
      Parameters:
      tickVisible - true to enable the slider tick marks.
    • isTickVisible

      public boolean isTickVisible()
      Returns whether the slider tick marks are enabled.
      Returns:
      true if slider tick mark are enabled.
    • getMinValue

      public int getMinValue()
      Get the minimum value for this preference.
      Returns:
      The minimum value for this preference.
    • setMinValue

      public void setMinValue(int minValue)
      Set the minimum value for this preference.
      Parameters:
      minValue - The minimum value to be set.
    • getMaxValue

      public int getMaxValue()
      Get the maximum value for this preference.
      Returns:
      The maximum value for this preference.
    • setMaxValue

      public void setMaxValue(int maxValue)
      Set the maximum value for this preference.
      Parameters:
      maxValue - The maximum value to be set.
    • getDefaultValue

      public int getDefaultValue()
      Get the default value for this preference.
      Overrides:
      getDefaultValue in class DynamicSpinnerPreference
      Returns:
      The default value for this preference.
    • setDefaultValue

      public void setDefaultValue(int defaultValue)
      Set the default value for this preference.
      Overrides:
      setDefaultValue in class DynamicSpinnerPreference
      Parameters:
      defaultValue - The default value to be set.
    • getProgress

      public int getProgress()
      Returns the current slider progress.
      Returns:
      The current slider progress.
    • setProgress

      public void setProgress(int progress)
      Get the current slider progress.
      Parameters:
      progress - The progress to be set.
    • getSeekInterval

      public int getSeekInterval()
      Get the seek interval for the slider.
      Returns:
      The seek interval for the slider.
    • setSeekInterval

      public void setSeekInterval(int seekInterval)
      Set the seek interval for the slider.
      Parameters:
      seekInterval - The seek interval to be set.
    • getUnit

      @Nullable public CharSequence getUnit()
      Get the optional unit text for the preference value.
      Returns:
      The optional unit text for the preference value.
    • setUnit

      public void setUnit(@Nullable CharSequence unit)
      Set the optional unit text for the preference value.
      Parameters:
      unit - The unit to be set.
    • setValue

      public void setValue(int value)
      Set the value for this preference.
      Parameters:
      value - The value to be set.
    • getValidValue

      public int getValidValue(int value)
      Returns the valid value after performing various checks.
      Parameters:
      value - The value to be checked.
      Returns:
      The valid value after performing various checks.
    • isControls

      public boolean isControls()
      Returns whether the slider slider buttons to increase or decrease the value are enabled.
      Returns:
      true to show slider buttons to increase or decrease the value.
    • setControls

      public void setControls(boolean controls)
      Set the slider controls to be enabled or disabled.
      Parameters:
      controls - true to show slider buttons to increase or decrease the value.
    • getDynamicSliderResolver

      @Nullable public DynamicSliderChangeListener<Slider> getDynamicSliderResolver()
      Returns the slider change listener to get the callback for seek events.
      Returns:
      The slider change listener to get the callback for seek events.
    • setDynamicSliderResolver

      public void setDynamicSliderResolver(@Nullable DynamicSliderChangeListener<Slider> dynamicSliderResolver)
      Set the slider change listener and value resolver to get the various callbacks.
      Parameters:
      dynamicSliderResolver - The resolver to be set.
    • getOnSliderControlListener

      @Nullable public DynamicSliderChangeListener<Slider> getOnSliderControlListener()
      Returns the slider change listener and value resolver to get the various callbacks.
      Returns:
      The slider change listener and value resolver to get the various callbacks.
    • setOnSliderControlListener

      public void setOnSliderControlListener(@Nullable DynamicSliderChangeListener<Slider> onSliderControlListener)
      Set the slider change listener to get the callback for control events.
      Parameters:
      onSliderControlListener - The listener to be set.
    • getProgressFromValue

      public int getProgressFromValue(int value)
      Returns the slider progress according to the supplied value.
      Parameters:
      value - The value to be converted into slider progress.
      Returns:
      The slider progress according to the supplied value.
    • getValueFromProgress

      public int getValueFromProgress()
      Returns the preference value according to the slider progress.
      Returns:
      The preference value according to the slider progress.
    • getSlider

      @Nullable public Slider getSlider()
      Get the slider to display and modify the preference value.
      Returns:
      The slider to display and modify the preference value.
    • getPreferenceValueView

      @Nullable public TextView getPreferenceValueView()
      Get the text view to show the value.
      Returns:
      The text view to show the value.
    • getControlLeftView

      @Nullable public ImageButton getControlLeftView()
      Get the image view to show the decrease button used by this preference.
      Returns:
      The image view to show the decrease button used by this preference.
    • getControlRightView

      @Nullable public ImageButton getControlRightView()
      Get the image view to show the increase button used by this preference.
      Returns:
      The image view to show the increase button used by this preference.
    • animateSlider

      public void animateSlider(int value)
      Set the preference value after animating the slider.
      Parameters:
      value - The preference value to be set.
    • onSharedPreferenceChanged

      public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, @Nullable String key)
      Specified by:
      onSharedPreferenceChanged in interface SharedPreferences.OnSharedPreferenceChangeListener
      Overrides:
      onSharedPreferenceChanged in class DynamicSpinnerPreference