Class DynamicCheckPreference

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

public class DynamicCheckPreference extends DynamicSimplePreference
A DynamicSimplePreference to provide the functionality of a SwitchPreference.
  • Field Details

    • DEFAULT_CHECK_STATE

      public static final boolean DEFAULT_CHECK_STATE
      Default value for the checked state.
      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 DynamicPreference
      Parameters:
      attrs - The attribute set to load the values.
    • 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 DynamicSimplePreference
    • 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 DynamicSimplePreference
    • 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()
      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
    • isChecked

      public boolean isChecked()
      Returns whether this preference is checked.
      Returns:
      true if this preference is checked.
    • setChecked

      public void setChecked(boolean checked)
      Set the state of the switch to be checked or unchecked.
      Parameters:
      checked - true if this preference is checked.
    • getSummaryUnchecked

      @Nullable public CharSequence getSummaryUnchecked()
      Get the optional summary for the unchecked state.
      Returns:
      The optional summary for the unchecked state.
    • setSummaryUnchecked

      public void setSummaryUnchecked(@Nullable String summaryUnchecked)
      Set the optional summary for the unchecked state.
      Parameters:
      summaryUnchecked - The unchecked summary to be set.
    • getCompoundButton

      @Nullable public CompoundButton getCompoundButton()
      Get the compound button used by this preference.
      Returns:
      The compound button used by this preference.
    • getOnCheckedChangeListener

      @Nullable public CompoundButton.OnCheckedChangeListener getOnCheckedChangeListener()
      Returns the checked change listener.
      Returns:
      The checked change listener to get the callback if switch state is changed.
    • setOnCheckedChangeListener

      public void setOnCheckedChangeListener(@Nullable CompoundButton.OnCheckedChangeListener onCheckedChangeListener)
      Set the checked change listener to get the callback if switch state is changed.
      Parameters:
      onCheckedChangeListener - The listener to be set.