All Implemented Interfaces:
Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, ViewManager, ViewParent, BaseWidget, DynamicTintWidget, DynamicWidget
Direct Known Subclasses:
DynamicColorPicker, DynamicInfoView, DynamicItemView, DynamicPreference, ThemePreview

public abstract class DynamicView extends DynamicFrameLayout
A DynamicFrameLayout with basic functionality to create views according to the requirements.
  • Field Details

    • mUpdateRunnable

      protected final Runnable mUpdateRunnable
      Runnable to post the update.
  • 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
      Overrides:
      loadFromAttributes in class DynamicFrameLayout
      Parameters:
      attrs - The supplied attribute set to load the values.
    • onLoadAttributes

      protected void onLoadAttributes(@Nullable AttributeSet attrs)
      Load values from the supplied attribute set.
      Parameters:
      attrs - The attribute set to load the values.
    • getLayoutRes

      @LayoutRes protected abstract int getLayoutRes()
      This method will be called to get the layout resource for this view.

      Supply the view layout resource here to do the inflation.

      Returns:
      The layout resource for this view.
    • onInflate

      protected abstract void onInflate()
      This method will be called after loading the attributed.

      Initialize the view layout here.

    • onUpdate

      protected abstract void onUpdate()
      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.

    • update

      public void update()
      Manually update this view by calling onUpdate() method.

      Useful in some situations to restore the view state.

    • postUpdate

      public void postUpdate()
      Manually update this view by calling onUpdate() method via a Runnable.

      Useful in some situations to restore the view state on main thread.

    • onEnabled

      protected void onEnabled(boolean enabled)
      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.

      Parameters:
      enabled - true if this view is enabled and can receive click events.
    • getBackgroundView

      @Nullable public abstract View getBackgroundView()
      This method will be called to return the optional background view.

      It will be useful in tinting the background according to the contrast with color.

      Returns:
      The optional background view.
    • 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
      Overrides:
      setEnabled in class View
      Parameters:
      enabled - true if this widget is enabled and can receive click events.
    • setClickable

      public void setClickable(boolean clickable)
      Overrides:
      setClickable in class DynamicFrameLayout
    • setOnClickListener

      public void setOnClickListener(@Nullable View.OnClickListener l)
      Overrides:
      setOnClickListener in class DynamicFrameLayout
    • setLongClickable

      public void setLongClickable(boolean longClickable)
      Overrides:
      setLongClickable in class DynamicFrameLayout
    • setOnLongClickListener

      public void setOnLongClickListener(@Nullable View.OnLongClickListener l)
      Overrides:
      setOnLongClickListener in class DynamicFrameLayout
    • 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 DynamicFrameLayout