Class DynamicSeekBarPreference

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

public class DynamicSeekBarPreference extends DynamicSpinnerPreference
A DynamicSpinnerPreference to provide the functionality of a seek bar 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:
  • 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
    • setSeekEnabled

      public void setSeekEnabled(boolean seekEnabled)
      Enable or disable the seek bar.
      Parameters:
      seekEnabled - true to enable the seek bar.
    • isSeekEnabled

      public boolean isSeekEnabled()
      Returns whether the seek bar is enabled.
      Returns:
      true if seek bar is 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 seek bar progress.
      Returns:
      The current seek bar progress.
    • setProgress

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

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

      public void setSeekInterval(int seekInterval)
      Set the seek interval for the seek bar.
      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 seek bar seek bar buttons to increase or decrease the value are enabled.
      Returns:
      true to show seek bar buttons to increase or decrease the value.
    • setControls

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

      @Nullable public SeekBar.OnSeekBarChangeListener getDynamicSeekBarResolver()
      Returns the seek bar change listener to get the callback for seek events.
      Returns:
      The seek bar change listener to get the callback for seek events.
    • setDynamicSeekBarResolver

      public void setDynamicSeekBarResolver(@Nullable SeekBar.OnSeekBarChangeListener dynamicSeekBarResolver)
      Set the seek bar change listener and value resolver to get the various callbacks.
      Parameters:
      dynamicSeekBarResolver - The resolver to be set.
    • getOnSeekBarControlListener

      @Nullable public SeekBar.OnSeekBarChangeListener getOnSeekBarControlListener()
      Returns the seek bar change listener and value resolver to get the various callbacks.
      Returns:
      The seek bar change listener and value resolver to get the various callbacks.
    • setOnSeekBarControlListener

      public void setOnSeekBarControlListener(@Nullable SeekBar.OnSeekBarChangeListener onSeekBarControlListener)
      Set the seek bar change listener to get the callback for control events.
      Parameters:
      onSeekBarControlListener - The listener to be set.
    • getValueFromProgress

      public int getValueFromProgress()
      Returns the preference value according to the seek bar progress.
      Returns:
      The preference value according to the seek bar progress.
    • getSeekBar

      @Nullable public AppCompatSeekBar getSeekBar()
      Get the seek bar to display and modify the preference value.
      Returns:
      The seek bar 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.
    • onSharedPreferenceChanged

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